My Code:
b=list(input("entr"))
print(b)
for a in b :
if a>5:
print(a)
I got this error :
TypeError: '>' not supported between instances of 'str' and 'int'
My Code:
b=list(input("entr"))
print(b)
for a in b :
if a>5:
print(a)
I got this error :
TypeError: '>' not supported between instances of 'str' and 'int'
Try this,
b=list(map(int,input("Enter: ").split()))
It will take int
as inputs and convert into list.
Ex:
>>> b=list(map(int,input("Enter").split()))
Enter: 3 4 5 6 7
>>> for a in b :
if a>5:
print(a)
6
7