jeudi 26 mars 2015

Python else is not working in If/else statement [duplicate]


This question already has an answer here:




I am a beginner, and this program is supposed to run like rolling dice.


It should generate a random # and ask to roll again, no more than 3 times.


When I type N to invoke the else statement it doesnt break off it keeps going with the loop.



from random import randint

count = 0
def rolling():
print "We are rolling!!!"
print " "
print "You rolled a: ", randint(1, 6)
print " "

roll = raw_input('Type Y if you would like to roll: ' )

while count < 3:
if roll == "y" or "Y":
rolling();
again = raw_input("Would you like to roll again? Y or N: ")
if again == "y" or "Y":
rolling();
count = count + 1
else:
print "Goodbye"

Aucun commentaire:

Enregistrer un commentaire