+ 1

concat a string to another string in Python

Hey there! Consider this string - - > mystring="1 2 23" and a shorter string - -> b="0" I need to concat b to every elements of mystring. note that mystring is a string not a list. so if i print the result, it would be: "01 02 023" What can i do?

25th Nov 2017, 11:59 AM
Aref moloughi
Aref moloughi - avatar
1 Antwort
+ 1
a="1 2 23" b="0" c = " ".join(b+i for i in a.split()) print (c)
25th Nov 2017, 12:31 PM
yuri