-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroll_dice_game
More file actions
49 lines (37 loc) · 1.18 KB
/
roll_dice_game
File metadata and controls
49 lines (37 loc) · 1.18 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
import random
def roll ():
min_value =1
max_value =6
roll = random.randint(min_value,max_value)
return roll
while True:
players = input ('Enter the Number of players between 2-4: ')
if players.isdigit():
players = int(players)
if 2<= players <=4:
break
else:
print ('must be beween 2-4')
else :
print('invalid option')
max_score = 30
player_score = 0
while max(player_score)< max_score:
for player_idx in range (players):
print ('\n player number',player_score[player_idx])
current_score =0
while True:
should_roll = input('would you like to roll(y)')
if should_roll.lower != 'y':
break
value =roll()
if value == 1:
print('you rolled a 1 .Turn done')
current_score=0
break
else:
current_score +=1
print ('you rollesd a: ' , value)
print ('Your score is:', current_score)
player_score[player_idx] += current_score
print ('your total score is ', player_score[player_idx])