Here is a loop to make sure players of my small game input valid answers but the while loop conintues infinitely, even when the conditions are satisfied to break the loop:
initialize = ''
while initialize != 'yes' or initialize != 'no':
print('\nWould you like to play?')
initialize = input('Yes or No? ').lower().strip()
if initialize == 'yes':
print('\nHappy to see you.\n')
elif initialize == 'no':
print('\nNo worries.\n\nThanks for stopping by!')
else:
print('\nSorry, I didn\'t catch that')
print('please wait as game loads')
print('\nYou\'re very important to us\n')
if 'yes' or 'no' is typed in the correct if statement runs but the loop continues: Would you like to play? Yes or No? yes
Happy to see you.
Would you like to play? Yes or No?
Aucun commentaire:
Enregistrer un commentaire