22 lines
534 B
Python
22 lines
534 B
Python
import random
|
|
|
|
dice = ["1", "2",]
|
|
|
|
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)
|
|
|
|
def roll_dice(num_dice)
|
|
roll_results = []
|
|
for _ in range(num_dice):
|
|
roll = random.randint(1, 6)
|
|
roll_results.append(roll)
|
|
|
|
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)
|
|
|