TypeError: can only concatenate str (not "int") to str code example

Example 1: TypeError: can only concatenate str (not "int") to str

print( "Alireza" + str(1980))

Example 2: TypeError: can only concatenate str (not "method") to str

You need to call it using () to get a string in return

Example 3: can only concatenate str (not "int") to str

# To solve the issue, just add str to your number or value like:

print( "Alireza" + str(1980))

Example 4: TypeError: can only concatenate str (not "int") to str

# Instead of using " + " operator
print( "Alireza" + 1980)
# Use comma " , " operator
print( "Alireza" , 1980)

Tags:

Misc Example