-4

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'

Rahul Agarwal
  • 4,034
  • 7
  • 27
  • 51

1 Answers1

1

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
shaik moeed
  • 5,300
  • 1
  • 18
  • 54