From bea881624fb14f0717370030a3c90ca47360a0f5 Mon Sep 17 00:00:00 2001 From: Stephen Deaton Date: Mon, 10 Jun 2024 13:20:37 -0400 Subject: [PATCH] 2nd commit first solo --- Python/Examples/dice.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Python/Examples/dice.py b/Python/Examples/dice.py index 41ead19..7dd9a01 100644 --- a/Python/Examples/dice.py +++ b/Python/Examples/dice.py @@ -1,4 +1,6 @@ -dice = ["1", "2", "3", "4"] +import random + +dice = ["1", "2",] def parse_input(input_string): if input_string.strip() in dice: @@ -7,6 +9,12 @@ def parse_input(input_string): 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)