TypeError: Object is Not Iterable

TypeError: 'int' object is not iterable

Quick Answer

You are trying to iterate over something that is not iterable, like an integer or NoneType. Ensure you are looping over a list, tuple, string, or other iterable, not a scalar value.

Why This Happens

A for loop, unpacking, or functions like list(), sum(), and join() require an iterable. If you pass a single integer, None, or other non-iterable, Python raises this error.

The Problem

count = 5
for i in count:
    print(i)

The Fix

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

Step-by-Step Fix

  1. 1

    Check the type of your variable

    Print type(variable) to see what you are iterating over.

  2. 2

    Wrap in an iterable

    Use range(n) for integers, or wrap a single value in a list: [value].

  3. 3

    Fix the data source

    If a function returns None or a scalar when you expect a list, fix the function.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free