ShareYourGroupShareYourGroupError Explainer

Python TypeError: 'int' object is not iterable

A plain-words explanation of this Python message: what it means, the usual causes, and the steps that fix it.

The messageTypeError: 'int' object is not iterable

Make the error yourself

Run with Python 3.14.10. This is the smallest example we could find that shows it.

Python program (main.py)

for i in 5:
    print(i)

Output (the real message)

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    for i in 5:
             ^
TypeError: 'int' object is not iterable

Why it happens

A for loop needs something it can walk through: a list, a string, a tuple, a dictionary or range(...). A single number is not a collection. The type in the message tells you what Python found instead: int, float, NoneType. A common version is sum(5) or list(5), and another is a function that should return a list but returns a number or None.

How to fix it

  1. To repeat something 5 times use range(5).
  2. If you meant to loop over a list, check that the variable really holds the list: print(type(x)).
  3. If the type is NoneType, the function that produced it forgot to return.

The corrected version

Python program (main.py)

for i in range(5):
    print(i)

Output (the corrected version)

0
1
2
3
4

How to avoid it

Name variables for what they hold (names, count) so that you do not loop over a count.

Questions

Why is a string iterable but a number is not?

A string is a sequence of characters. A number is a single value with no parts.

This is an independent guide. It is not connected with Python, Microsoft, Google, GitHub or the Git project. Product names belong to their owners. Examples were run on 13 November 2026 in a practice folder or a blank workbook; your version may word a message slightly differently.