-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkingcode.py
More file actions
92 lines (84 loc) · 2.3 KB
/
workingcode.py
File metadata and controls
92 lines (84 loc) · 2.3 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from replit import clear
from art import logo
import random
def random_selection():
selected_type=random.choice(list(cards))
# print(selected_type)
# print(cards[selected_type])
selected_card=random.choice(cards[selected_type])
# print(selected_card)
cards[selected_type].remove(selected_card)
# print(cards[selected_type])
return selected_card
def final():
(f" Your final hand: {player}, final score: ", sum(player))
print(f" Dealer's final hand: {dealer}, final score: ",sum(dealer))
if sum(player) == 21:
print("Win with a Blackjack 😎")
elif sum(dealer) == 21:
print("Opponent Win with a Blackjack 😎")
elif sum(player) > 21:
print("You went over. You lose 😭")
elif sum(dealer) > 21:
print("Opponent went over. You win 😁")
elif sum(player)>sum(dealer):
print("You win 😃")
elif sum(player)<sum(dealer):
print("You loss 😤")
else:
print("Draw 🙃")
print(cards)
n=input("Do you want to play a game of Blackjack? Type 'y' or 'n': ")
if n == "n":
answer=False
else:
answer=True
while answer:
values=[11,2,3,4,5,6,7,8,9,10,10,10,10]
val1=values.copy()
val2=values.copy()
val3=values.copy()
val4=values.copy()
cards={
"Speet":val1,
"Hass":val2,
"Sheria":val3,
"deman":val4
}
player=[]
dealer=[]
continue_playing= True
clear()
print(logo)
for i in range(4):
result=random_selection()
if i % 2 == 0:
player.append(result)
else:
dealer.append(result)
print(f" Your cards: {player}, current score: ",sum(player))
print(f" Dealer's first card: {dealer[0]}")
while continue_playing:
m=input("Type 'y' to get another card, type 'n' to pass: ")
if m == 'n':
continue_playing = False
final()
else:
result=random_selection()
player.append(result)
print(f" Your cards: {player}, current score: ",sum(player))
if sum(player) > 21:
continue_playing = False
final()
else:
result=random_selection()
dealer.append(result)
print(f" Dealer's cards: {dealer}, current score: ",sum(dealer))
if sum(dealer) > 21:
continue_playing = False
final()
n=input("Do you want to play a game of Blackjack? Type 'y' or 'n': ")
if n == "n":
answer=False
else:
answer=True