# Python: Can not understand why I am getting the error: Can not concatenate 'int' and 'str' object

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

This error is coming because the interpreter is replacing the %d with i and then trying to add 1 to a str, ie, adding a str and an int. In order to correct this, just surround the i+1 in parentheses.

## example

print("\

Num %d" % (i+1))
Updated on 12-Mar-2020 12:31:58