-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
56 lines (42 loc) · 1.06 KB
/
Copy pathfunctions.py
File metadata and controls
56 lines (42 loc) · 1.06 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
# 04 08 2026
# using functions
import random
def UpdateScoreAndPlayer(score1,score2,player,dice):
if choice != 1:
if player == 1:
score1 += dice
else:
score2 += dice
else:
if player == 1:
player = 2
score1 = 0
else:
player = 1
score2 = 0
return score1,score2,player
def hold(player):
if player == 1:
player = 2
else:
player = 1
return player
score1 = 0
score2 = 0
player = 1
while score1 < 20 and score2 < 20:
print("1.Roll \n 2.Hold")
choice = input("Enter your choice: ")
if choice == '1':
dice = random.randint(1,6)
score1,score2,player = UpdateScoreAndPlayer(score1,score2,player,dice)
print("Current Player: ",player)
print(f"Player 1 Score: {score1}")
print(f"Player 2 Score: {score2}")
elif (choice == '2'):
player = hold(player)
print("Current Player: ",player)
if score1 >= 20:
print ("Player 1 Wins!")
else:
print ("Player 2 Wins!")