Python throws the error ‘int’ object is not iterable, when we try to use an integer value as an array or list. If you want to make your variable iterable, you need to convert it into string.

Consider this code example –

a = 45678
iterableA = list(a)

This will throw error, int object is not iterable. Although we want to access all the digits in the number separately but this is not a correct way to do that.

The correct code is –

a = 45678
iterableA = list(str(a))

or, we can also do –

a = 45678
iterableA = [a]

    Tweet this to help others

Live Demo

Demo might not work in private window (incognito)


About the Author


I am Akash Mittal, an overall computer scientist. If you want to guest post, need help in your projects, want to advertise, Feel free to contact me at [email protected]

View All Articles