charoniv
charoniv

Reputation: 13

Getting TypeError: '>' not supported between instances of 'str' and 'int' for input numbers

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

Answers (1)

Dinuda Yaggahavita
Dinuda Yaggahavita

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

Related Questions