Python refuses to guess how to combine unlike types. Adding a string to an integer, subtracting a list from a number, or multiplying text by a string raises this TypeError, and the message names the operator and both types involved, in order. The overwhelmingly common cause in beginner code is input(), which always returns a string, meeting an arithmetic operation that expected a number.
age = input("Age: ") # input() always returns a string
next_year = age + 1
Traceback (most recent call last):
File "main.py", line 2, in <module>
TypeError: unsupported operand type(s) for +: 'str' and 'int'
# fixed: convert the text to a number first
next_year = int(age) + 1
input() immediately: age = int(input(...)) or float(...) for decimals. Data from files, JSON, and web forms is likewise text until converted.type(x) for the suspects when the source is unclear. Values that look numeric in output ("5" prints like 5) betray themselves only by type.str(number) or an f-string: f"Total: {total}". Python will not concatenate a number into a string implicitly.__add__ and friends, or convert the object to a plain value first.If the types in the message are types you never wrote (a library's classes), an API returned an unexpected shape, often None or a string where a number was promised. Inspect the actual returned object rather than the documentation's ideal version of it.
Why does this happen so often with input()? Because input() returns a string by design, always, even when the user types digits. Every interactive beginner program meets this error exactly once per numeric field until converting at input becomes habit.
Other languages add a number to a string without complaint. Why not Python? Languages that coerce silently guess which way to convert, and guess wrong in ways that hide bugs (the classic “5” + 1 becoming “51”). Python's design refuses the guess and makes the programmer state the conversion, which is why the error exists.