mardi 28 mars 2017

while loop doesn't stop, with if statement as nested loop

see my code below:

x = -1
num = -9

print("For exit press 0")

while (x != 0):
    num = input("Enter a number  :")
    print("You entered: ", num)
    x = num
    if x == 0:
        break


print("Good bye!")

The code doesn't stop even if 0 is fed as value. what could be the possible reason?. Thanks!

Aucun commentaire:

Enregistrer un commentaire