-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdice_stimulator.py
More file actions
88 lines (76 loc) · 1.8 KB
/
dice_stimulator.py
File metadata and controls
88 lines (76 loc) · 1.8 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
# Built-in Modules
import random
dice_drawing = {
1: (
"-------",
"| |",
"| o |",
"| |",
"-------",
),
2: (
"-------",
"|o |",
"| |",
"| o|",
"-------",
),
3: (
"-------",
"|o |",
"| o |",
"| o|",
"-------",
),
4: (
"-------",
"|o o|",
"| |",
"|o o|",
"-------",
),
5: (
"-------",
"|o o|",
"| o |",
"|o o|",
"-------",
),
6: (
"-------",
"|o o|",
"|o o|",
"|o o|",
"-------",
),
}
def extract_dice_from_dict():
"""Extract dice from the dictionary"""
list_of_keys = []
for key in dice_drawing.keys():
list_of_keys.append(key)
return list_of_keys
def roll_dice():
"""Choose a dice from the list of dices"""
list_of_keys = extract_dice_from_dict()
dice1 = random.choice(list_of_keys)
dice2 = random.choice(list_of_keys)
for i in dice_drawing[dice1]:
print(i)
for i in dice_drawing[dice2]:
print(i)
def main():
"""Main function"""
print("Welcome To Dice Stimulator!\n")
while True:
user_input = input("Want to roll the dice? Type Yes or No: ").lower()
if user_input == 'yes':
roll_dice()
elif user_input == 'no':
print("Thank you for using the Dice Stimulator!")
exit()
else:
print("Please provide a valid input.")
exit()
if __name__ == '__main__':
main()