+ 1
Code doesn't work
num=input("nter the number\n") print (num) if num > 5: print("Bigger than 5") if num <=47: print("Between 5 and 47")
3 Answers
+ 11
Hello
You should know that
â input returns a string not a number
which means
num is a string
( to verify this is true: add
print(type(num))
after
num=input(...)
and re-execute your code )
Anyways, to resolve your problem, just use
num = int(input("enter number\n"))
to tell python to convert the inputed string into an integer
Hope I helped you! â
+ 5
I have a solution to your problem, the error you got said that you were trying to compare a string to an integer so you have to change "num" to an integer using this code:
num = int(num)
use it like this:
num=input("enter the number\n")
print(num)
num = int(num)
if num > 5:
print("Bigger than 5")
if num <=47:
print("Between 5 and 47")