How to concatenate a int to a str in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to concatenate a int to a str in python?

sudo-asap says I don't want a whitespace between a int type and a str type so how do I accomplish this without an error, thanks

20th May 2020, 12:12 AM
sudo-asap
sudo-asap - avatar
3 Answers
+ 2
Convert the int value to string and then concatenate it with the string value like this: num=10 name="Jack" new_name=name+str(num)
20th May 2020, 12:31 AM
Ahmed Muhammed
Ahmed Muhammed - avatar
+ 1
Lets see your code so we can see exactly what the problem is
20th May 2020, 12:27 AM
Slick
Slick - avatar
+ 1
Ok so the only way to concatenate an int with str is to make the int a str type. Ok thanks.
20th May 2020, 12:49 AM
sudo-asap
sudo-asap - avatar