-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
  • 3,940
  • 7
  • 26
  • 47

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
  • 4,321
  • 1
  • 14
  • 46