paint-brush
How to fix the Python TypeError: ‘int’ Object is not Iterableby@itsmycode
10,235 reads
10,235 reads

How to fix the Python TypeError: ‘int’ Object is not Iterable

by Srinivas RamakrishnaSeptember 9th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow
EN

Too Long; Didn't Read

Int objects are not directly iterable as they hold a single integer value and do not contain the \*\*‘`__iter__`‘ \** method. Instead of using int, try using list if it makes sense, and it can be iterated using for and while loop easily. Try using the `range()` method in the for loop, which will eventually generate a list of sequential numbers.
featured image - How to fix the Python TypeError: ‘int’ Object is not Iterable
Srinivas Ramakrishna HackerNoon profile picture
Srinivas Ramakrishna

Srinivas Ramakrishna

@itsmycode

L O A D I N G
. . . comments & more!

About Author

Srinivas Ramakrishna HackerNoon profile picture
Srinivas Ramakrishna@itsmycode

TOPICS

Languages

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite