0
Can i concatenate to different data type in 1 string
eg 268.4537 is float and "happy" is string I want out put as "268.4537 happy" how can I archive this
4 Answers
+ 4
You only need to convert the data type with the str() function:
my_num = 3.8
my_str = "Hello"
print (my_str + str(my_num))
There are other ways to do what you like (format a string), here you have more information:
http://www.pythonforbeginners.com/concatenation/string-concatenation-and-formatting-in-JUMP_LINK__&&__python__&&__JUMP_LINK
+ 2
In what language?
+ 1
thanks mickel