-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (23 loc) · 757 Bytes
/
Copy pathmain.py
File metadata and controls
33 lines (23 loc) · 757 Bytes
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
import random
again = True
count = 0 # Counter to track number of rolls
while again:
try:
num = int(input("How many dice do you want to roll?: "))
if num <= 0:
print("Please enter a number greater than 0.\n")
continue
except ValueError:
print("Invalid input! Please enter a number.\n")
continue
print("Rolling dice...\n")
for i in range(num):
print(f"Dice {i+1}: {random.randint(1, 6)}")
count += 1
another_roll = input("\nDo you want to roll dice again? (y/n): ")
if another_roll.lower() == "y":
continue
else:
print("\nYou are quitting the game. Game Closed!")
print("Total times you rolled the dice:", count)
break