vendredi 20 mars 2015

while loop with the if statement in python


print ("Selection of the mode\n Easy \n Moderate \n tough")
selection = int(input("Please enter the right Choice!! > "))

while selection != '':
if selection == 1:
print("\ngoodluck")
elif selection == 2:
print('\nyou are brave')
elif selection == 3:
print ('\nyou must be kidding')
selection = int(input("Please enter the right Choice!!! > "))


I am making a small program, new to python so have a bit of understanding problem, need to know my error when the user have typed in the correct selection like 1 or 2 or three it should go in a loop and run the if statement. Once that is done it should exit. But apparently that is not working perfectly.


Aucun commentaire:

Enregistrer un commentaire