Home > Mobile >  How can I fix TypeError: 'int' object is not iterable?
How can I fix TypeError: 'int' object is not iterable?

Time:10-10

How can I fix TypeError: 'int' object is not iterable?

N = list(input("Enter long number: "))

Even = []
Odd = []

for i in list (N):
    if i % 2 == 0:
        Even.count (i)
    elif i % 2 == 1:
        Odd.count (i)

print (f"Even: {Even}")
print (f"Odd: {Odd}")

CodePudding user response:

can you try this?

N = list(input("Enter long number: "))

Even = []
Odd = []

for i in N:
    i = int(i)
    if i % 2 == 0:
        Even.append(i)
    elif i % 2 == 1:
        Odd.append(i)

print (f"Even: {Even}")
print (f"Odd: {Odd}")
  • Related