jeudi 5 janvier 2017

Python 'while' loop doesn't work properly [duplicate]

This question already has an answer here:

I wrote the following program that asks the user for a number and verifies if it's correct or not. However, the while loop doesn't work as it should; no matter what the user's response is, the while loop repeats the question once and proceeds to print("Done"). Is there something wrong with the code I wrote (the else section doesn't work at all).

print("Welcome")

number = input("Insert a number?")
number_user_int = int(number)

print(number_user_int)
verify_number =  input("Is it correct?")

while verify_number == "N" or "n":
    print("Oops.. Let's try again")
    number = input("Insert a number?")
    number_user_int = int(number)
    print(number_user_int)
    verify_number =  input("Did we get your response correctly?")
    if verify_number == "Y" or "y":
      print("Let's move on")
      break
    else: 
      print("Let's move on")
print("Done")

Aucun commentaire:

Enregistrer un commentaire