0

Can you explain - - Integer object isn't iterable?

25th Dec 2020, 5:33 AM
Name
Name - avatar
2 odpowiedzi
+ 2
you will face this error if you are trying to iterate over an integer object example : x=1234 for i in x : print(i) #Error #integer object isn't iterable means you can't iterate over an integer.. Solution to this problem : converting integer into string using str() x=1234 for i in str(x) : print(int(i)) #output : 1 2 3 4 https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_iterators.asp
25th Dec 2020, 6:09 AM
Ratnapal Shende
Ratnapal Shende - avatar
+ 1
Thanks Shende
29th Dec 2020, 9:16 AM
Name
Name - avatar