Reputation: 13
number = input ("enter a number : ")
if number > 10:
print ("bigger than 10")
elif number < 10:
print ("under 10")
How can I fix this error? I dont have any str:
TypeError: '>' not supported between instances of 'str' and 'int'
Upvotes: 1
Views: 61
Reputation: 990
You are comparing data between str and int.
By default input()
returns string.
Solution:
number = int(input ("enter a number : ") )
if (number > 10):
print ("bigger than 10")
elif (number < 10):
print ("under 10")
Upvotes: 1