When you are running or creating a Python script and want to avoid “Type Errors” you can do it by converting an integer to a string variable. You will only be able to concatenate an integer with message after converting int to string in python. The str() method in Python helps you do it.
Launch your IDE first and in my case, I am using NotePad++ to Make Python Script and Run it in IDE.
After creating .py file write your code in which you want to Convert Int to String in Python language.
You have to type str(variable name) for example str(number).
Press “Enter” and str() method will run to convert an integer to a string. Here’s an example code:
answer=input("Enter Any Number: ");
print("Answer After Adding 10 to Your Entered Number is "+str(answer));
The example above used the prompt user to enter a number and once it is entered int() method cast the variable to integer and add ten in the user’s entered number. Then, the “str” function converts the integer to a string so that Python can concatenate and print out the answer.
Without using “str()” method to convert the integer to a string in Python will give you “TypeError: cannot concatenate “str” and “int” objects” error.