-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRollDice.py
More file actions
69 lines (64 loc) · 2.43 KB
/
RollDice.py
File metadata and controls
69 lines (64 loc) · 2.43 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
import random #import random module
#list for dice eyes
EYES_DICE = [
"┌─────────┐\n"
"│ │\n"
"│ ● │\n"
"│ │\n"
"└─────────┘",
"┌─────────┐\n"
"│ ● │\n"
"│ │\n"
"│ ● │\n"
"└─────────┘",
"┌─────────┐\n"
"│ ● │\n"
"│ ● │\n"
"│ ● │\n"
"└─────────┘",
"┌─────────┐\n"
"│ ● ● │\n"
"│ │\n"
"│ ● ● │\n"
"└─────────┘",
"┌─────────┐\n"
"│ ● ● │\n"
"│ ● │\n"
"│ ● ● │\n"
"└─────────┘",
"┌─────────┐\n"
"│ ● ● │\n"
"│ ● ● │\n"
"│ ● ● │\n"
"└─────────┘",
]
#choice roll dice or no
yn = str(input("Roll dice? (yes/no) => ").lower())
while True:
if yn == "yes":
YOUR_DICE = [] # list to store your dice roll
dices = input("How many dice to roll? => ")
if dices.isdigit(): #to check whether "dices" is a number or not
dices = int(dices)
else:
print("Please input a number")
continue
for i in range(0, dices):
dice1 = random.randint(1, 6) #random is using to get 1 random integer
YOUR_DICE.append(dice1) #append to add random result to the list
print(EYES_DICE[dice1-1]) #print the eye dice
print("\nYour dices are: ", end='')
for i in YOUR_DICE: #print results in integer format
print(i, end= " ")
while True:
again = str(input("\nRoll again?? (yes/no) => "))
if again == "yes":
break #break to stop the loop
elif again == "no":
exit() #exit() to terminate the program
else:
print("Please enter yes/no!!")
elif yn == "no":
exit() #exit() is using to terminate the program
else:
print("Please enter yes/no!!")