0
How do i concatenate two strings and a number
3 Respuestas
+ 13
out = "1"+str(2)+"3"
+ 6
"ham"+"eggs" + str(2) == "hameggs2"
strings are concatenated with + operator. to concatenate a number to a string, convert it to a string with str(your_number)
+ 3
With Python3 ( and 2.7 by import print function from __future__ module ^^ ), you can use the format() method of strings:
print("my {} string with {} parameters to insert".format("concatenated",2))
Replacement are implicitly in order of the parameters, but coul be write:
print("my {1} string with {0} parameters to insert".format(2,"concatenated"))