-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlack_jack.py
More file actions
42 lines (34 loc) · 909 Bytes
/
Black_jack.py
File metadata and controls
42 lines (34 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import random
cards=[11,2,3,4,5,6,7,8,9,10,10,10]
user=[]
dealer=[]
for x in range(2):
user.append(random.choice(cards))
dealer.append(random.choice(cards))
def score(list):
sum = 0
for x in list:
sum = sum + x
return sum
def result():
user_score=score(user)
dealer_score=score(dealer)
print(user," : ",user_score)
print(dealer," : ",dealer_score)
if 21>=user_score>=17:
if user_score>dealer_score:
print("user wins")
else :
print("user looses")
else:
print("user looses")
a=input("Enter y if you want a card or n if you dont want a card:")
if a=="y":
for x in range(2):
dealer.append(random.choice(cards))
user.append(random.choice(cards))
result()
if a =="n":
for x in range(3):
dealer.append(random.choice(cards))
result()