close

[Solved] TypeError: can only concatenate str (not “int”) to str

Hello Guys, How are you all? Hope You all Are Fine. Today am just trying to print this But I am facing following error TypeError: can only concatenate str (not “int”) to str in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How TypeError: can only concatenate str (not “int”) to str Error Occurs ?

I am just trying to print this. Here is my code.

print( "Born Year is " + 1980)

But I am facing following error.

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

How To Solve TypeError: can only concatenate str (not “int”) to str Error ?

  1. How To Solve TypeError: can only concatenate str (not “int”) to str Error ?

    To Solve TypeError: can only concatenate str (not “int”) to str Error You Can’t Print String And Integer together without defining datatype. just add str to your number or value. Just like below code. print( “Born Year is ” + str(1980)) And the result as: Born Year is 1980 Second solution is You Can also Use comma ” , “ operator instead of ” + “.

  2. TypeError: can only concatenate str (not “int”) to str

    To Solve TypeError: can only concatenate str (not “int”) to str Error You Can’t Print String And Integer together without defining datatype. just add str to your number or value. Just like below code. print( “Born Year is ” + str(1980)) And the result as: Born Year is 1980 Second solution is You Can also Use comma ” , “ operator instead of ” + “.

Solution 1: just add str to your number or value

You Can’t Print String And Integer together without defining datatype. just add str to your number or value. Just like below code.

print( "Born Year is " + str(1980))

And the result as:

Born Year is 1980

Solution 2: Use comma ” , ” operator

You Can also Use comma ” , ” operator instead of ” + “. Just like below.

print( "Born Year is " , str(1980))

And the result as:

Born Year is 1980

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment