lundi 23 mai 2016

If/Then statement not working inside of while loop [duplicate]

This question already has an answer here:

The if/else statement inside of this loop will not work. If I enter "no" it still continues the loop. I don't understand why, any help would be appreciated.

while keepPlaying == True:
    play = input(str('Would you like to play rock, paper, scissors? Yes or no?\n'))

    if play == str('yes') or str('Yes'):
        playerChoice = input(str('Ok! what\'s your choice?\n'))
    else:
        keepPlaying = False

print ('Thanks for playing.')

I've put the code through a visualizer and even if the variable play != yes or Yes it still chooses the == to path.

Aucun commentaire:

Enregistrer un commentaire