While Loop, Input, If, Elif, Else


#1

The goal is to ask the user to enter a number between 50 and 100. If they enter a number less than 50, the program prints “Too low!”, if they enter a number greater than 100, the program prints “Too high!”, if they enter a number between 50 and 100, the program ends.

Can anyone tell me what is wrong with my code and why it answers back as “Too high!” no matter what I type in? Using Python3.

while True:
tab num = input("Enter a number between 50 and 100: ")
tab if num < “50”:
tab tab print(“Too low!”)
tab elif num > “100”:
tab tab print(“Too high!”)
tab else:
tab tab break


#2

Hi, @cassiealexa,

Why do you have quotes around the numbers in the conditional block headers?

Also remember that you need to convert the user input to a number.


#3

Hi! Thanks so much I see what I was supposed to do. I was inputting the user input as a string where they are supposed to be integers, instead of converting the user input into an integer. Thanks again! Makes sense now.