TypeError: Unsupported Operand Types

TypeError: unsupported operand type(s) for +: 'int' and 'str'

Quick Answer

You are trying to use an operator between incompatible types, like adding an integer to a string. Convert one operand to match the other type before performing the operation.

Why This Happens

Python does not implicitly convert types during arithmetic or concatenation. Unlike JavaScript, adding an int to a str is not allowed. You must explicitly convert using str(), int(), or float().

The Problem

age = 25
message = 'I am ' + age + ' years old'

The Fix

age = 25
message = f'I am {age} years old'
# Or: message = 'I am ' + str(age) + ' years old'

Step-by-Step Fix

  1. 1

    Identify the types involved

    The error message tells you the two types. Look at the variables on each side of the operator.

  2. 2

    Convert to matching types

    Use str() for string concatenation, or int()/float() for math.

  3. 3

    Use f-strings

    F-strings handle type conversion automatically: f'{value}'.

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