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

PythonServer Side ProgrammingProgramming

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))
Published on 23-Apr-2018 20:37:41
Advertisements