From ba790c0c0f4f28129fdf46974ec805dbfd16c603 Mon Sep 17 00:00:00 2001 From: FitriRibbit <91612800+FitriRibbit@users.noreply.github.com> Date: Sat, 17 Sep 2022 03:36:15 -0700 Subject: [PATCH] Update dice rolling simulator.py Add option when dice 1 and 2 had same number, then game ended --- dice rolling simulator.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/dice rolling simulator.py b/dice rolling simulator.py index 0116f83..647b65c 100644 --- a/dice rolling simulator.py +++ b/dice rolling simulator.py @@ -46,15 +46,24 @@ def roll_dice(): "-----", ), - } - roll = input("Roll the dice? (Yes/No) : ") - while roll.lower() == "Yes". lower(): - dice1 = random.randint(1, 6) - dice2 = random.randint(1, 6) + } - print("dice rolled: {} and {}". format(dice1, dice2)) + roll = input("Roll The Dice ? (y/n): ") + + while roll.lower() == "Y".lower(): + dice1 = random.randint(1,6) + dice2 = random.randint(1,6) + + #when you get same number from both dice, player quit game + if dice1 == dice2: + print("dice rolled: {} and {}".format(dice1, dice2)) + print("You lose !!") + quit() + + print("dice rolled: {} and {}".format(dice1, dice2)) print("\n".join(dice_drawing[dice1])) print("\n".join(dice_drawing[dice2])) - - roll = input("Roll again? (Yes/no): ") + + roll = input("Roll again? (y/n): ") + roll_dice()