▲ 0 r/learnpython
BLACK JACK GAME
import random
print('welcome to black jack game')
cards = [2,3,4,5,6,7,8,9,10,10,10,10]
ucards = [random.choice(cards), random.choice(cards)]
print(f'your cards are {ucards}')
dcards = [random.choice(cards), random.choice(cards)]
print(f'dealer cards are [{dcards[0]}, x]')
draw = input('do you wanna draw a card, y or n: ')
while draw == 'y':
ucards.append(random.choice(cards))
print(ucards)
draw = input('do you wanna draw a cards, y or n: n')
if sum(ucards)>21:
print('you lost')
break
while draw == 'n' and sum(dcards)<17:
dcards.append(random.choice(cards))
print(f'dealer cards are {dcards}')
if sum(dcards)<=21:
if sum(ucards)> sum(dcards):
print("you win")
if sum(dcards)>sum(ucards):
print('dealer wins')
if sum(dcards)==sum(ucards):
print('draw')
else:
print('you win')
how is this for a beginner.
this is from 100 days of code on udemy
u/ConditionProud93 — 18 hours ago