Hello everyone. Really, REALLY stuck here. I have written my code below. while

in the loop state, i am trying to set a counter where if

Reach 4 wins, options apply as per code. However I can't work

How to make this work? Can anyone help please? The conscious code is

otherwise cumbersome (and appreciated comments) but I'd rather

retain as close to the original as possible. Thank you!

```
import math
import dice
import random
# def PetalsAroundTheRose
# print introduction
print ("Would you like to play a game?")
print ("The game is...'Petals Around the Rose'. Cool")
print ("and catchy eh? Now, pay attention though as")
print ("the name of the game is important.")
print ("Each round, five dice are rolled and")
print ("You'll be asked for the score. (Hint? The score")
print ("will always be either 'zero' or an even number).")
print ("Your challenge is to deduce how the computer has")
print ("calculated the score.")
print ("You need to input your guess, after which")
print ("You'll learn if you were right. If not, you'll")
print ("be told the correct score & asked to roll again.")
print ("If you can guess correctly four times in a row,")
print ("You'll be declared the winner and receive the")
print ("majestic title of 'Potentate of the Rose'")
print ("")
# Ask user if up for the challenge!
# If no, exit game.
# If yes, roll the dice
play_petals = input("Are you up for the challenge? Enter 'y' for yes or 'n' for no: ")
print ("")
if play_petals == 'n':
print ("Really? Ok, see ya!")
exit()
if play_petals == 'y':
print ("Ok...here comes the first roll!")
else:
print("Sorry, wrong key? Press either y or n to continue please")
# Capture & maintain tally of correct guesses
# Four consecutive correct guesses required
# If incorrect, reset winning streak to zero
# Generate random roll of five dice
# Display resulting dice roll
die1 = random.randint(1,6)
die2 = random.randint(1,6)
die3 = random.randint(1,6)
die4 = random.randint(1,6)
die5 = random.randint(1,6)
result = dice.display_dice(die1, die2, die3, die4, die5)
# Define the roll result in line with rules
# Only include in total if is a 3 or a 5, other results in zero
def roll_result(die1):
if die1 == 1 or die1 == 2 or die1 == 4 or die1 == 6:
die1 = 0
elif die1 == 3:
die1 = 2
elif die1 == 5:
die1 = 4
return die1
def roll_result(die2):
if die2 == 1 or die2 == 2 or die2 == 4 or die2 == 6:
die2 = 0
elif die2 == 3:
die2 = 2
elif die2 == 5:
die2 = 4
return die2
def roll_result(die3):
if die3 == 1 or die3 == 2 or die3 == 4 or die3 == 6:
die3 = 0
elif die3 == 3:
die3 = 2
elif die3 == 5:
die3 = 4
return die3
def roll_result(die4):
if die4 == 1 or die4 == 2 or die4 == 4 or die4 == 6:
die4 = 0
elif die4 == 3:
die4 = 2
elif die4 == 5:
die4 = 4
return die4
def roll_result(die5):
if die5 == 1 or die5 == 2 or die5 == 4 or die5 == 6:
die5 = 0
elif die5 == 3:
die5= 2
elif die5 == 5:
die5 = 4
return die5
a = roll_result(die1)
b = roll_result(die2)
c = roll_result(die3)
d = roll_result(die4)
e = roll_result(die5)
total_roll_result = a + b + c + d + e
# Get players guess for roll
roll_guess = int(input("please enter your guess for this roll: "))
if roll_guess == total_roll_result:
print ("Well done! Correct!")
elif roll_guess % 2 == 0:
print ("No, sorry, it's", total_roll_result, 'not', roll_guess,"")
else:
print ("No, sorry, it's", total_roll_result, 'not', roll_guess,"")
print ("Remember,the answer will always be an even number")
# "keep playing?" loop
keep_playing = input("keep playing? Enter y or n: ")
print ("")
if keep_playing == 'n':
exit()
if keep_playing == 'y':
print ("Ok...here comes the next roll!")
def win_count():
win_count() == 0
correct == total_roll_result
while keep_playing == 'y':
die1 = random.randint(1,6)
die2 = random.randint(1,6)
die3 = random.randint(1,6)
die4 = random.randint(1,6)
die5 = random.randint(1,6)
result = dice.display_dice(die1, die2, die3, die4, die5)
a = roll_result(die1)
b = roll_result(die2)
c = roll_result(die3)
d = roll_result(die4)
e = roll_result(die5)
total_roll_result = a + b + c + d + e
roll_guess = int(input("please enter your guess for this roll: "))
if roll_guess == total_roll_result:
print ("Well done! Correct!")
elif roll_guess % 2 == 0:
print ("No, sorry, it's", total_roll_result, 'not', roll_guess,"")
else:
print ("No, sorry, it's", total_roll_result, 'not', roll_guess,"")
print ("Remember,the answer will always be an even number")
while keep_playing == 'y':
def win_count():
win_count() == 0
correct == total_roll_result
while win_count <= 4:
if roll_guess(correct):
win_count += 1
else:
win_count = 0
if win_count == 4:
print ("You keep getting this right!")
stop_playing = input("Do you want to keep playing? Enter y or n ")
if stop_playing == 'n':
exit()
if stop_playing == 'y':
print ("")
print ("Game Summary")
print ("------------")
print ("")
print ("You played X games:")
print ("")
print ("")
print ("Thanks for playing")
exit()
```