0
elif doesn't work ?
num = input("Enter a number:" ) if num == 5: print("Number is 5") elif num == 11: print("Number is 11") elif num == 7: print("Number is 7") else: print("Number isn't 5, 11 or 7") I think the spaces is the proplem but when i enter any number the result is always else
4 Answers
+ 4
An input is always treated as a string in Python (ver 3.x). And a string cannot equal a number. So you'd have to convert it to int (or float) first. Try this:
num = int(input("Enter a number:"))
+ 4
Check this out:
https://code.sololearn.com/ci4X0V5KR757/?ref=app
+ 2
You're welcome, Ragaey M.Ragaa! âș
+ 1
It works thanks