Initial commit of dice

This commit is contained in:
Stephen Deaton 2024-06-09 18:34:28 -04:00
parent 448e11a22f
commit 0de1c28104

13
Python/Examples/dice.py Normal file
View File

@ -0,0 +1,13 @@
dice = ["1", "2", "3", "4"]
def parse_input(input_string):
if input_string.strip() in dice:
return int(input_string)
else:
print(f"Please enter a number from {dice[0]} to {dice[-1]}.")
raise SystemExit(1)
num_dice_input = input(f"How many dice do you want to roll? [{dice[0]}-{dice[-1]}] ")
num_dice = parse_input(num_dice_input)
print(num_dice)