Python Forum

Full Version: Simple while loop only works on first attempt
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all

New to python any help much appreciated. When I run the code below if I enter No on the first attempt python prints "PLEASE CAN I HAVE ANOTHER ONE" AS EXPECTED. If I then enter yes on the next cycle it does not print thanks mum it keeps looping back to "Please can I have another one". Can some one help.

print("Mum can I have an ice cream?")

answer= input()

while answer == "No":
    print("Please can I have one")
    

    anwser = input()

    
print("Thanks mum")
typo in anwser = input()

>>> 'answer' == 'anwser'
False
Its been a long day.

Many thanks