Dec-14-2017, 07:01 PM
I have to program a dice game for my school homework and I am stuck on part of the program so would like so help please. The below code in Python should ask the users who wants to play user 1 or 2. It should then stay in the second while loop all the time the user enters "y" but it goes back to the first question when "y" is entered. What am I doing wrong.
while 1:
userTurn = input ("Enter player 1 or 2 : ")
while userTurn == 1:
userAnswer = raw_input ("Do you want to roll dice? Y or N : ")
if userAnswer == "Y" or "y":
print ("rolleing add random code")
if userAnswer == "N" or "n":
break
while 1:
userTurn = input ("Enter player 1 or 2 : ")
while userTurn == 1:
userAnswer = raw_input ("Do you want to roll dice? Y or N : ")
if userAnswer == "Y" or "y":
print ("rolleing add random code")
if userAnswer == "N" or "n":
break