how to join string in python code example
Example 1: python merge list into string
>>> sentence = ['this','is','a','sentence']
>>> '-'.join(sentence)
'this-is-a-sentence'
Example 2: join() python
numList = ['1', '2', '3', '4']
separator = ', '
print(separator.join(numList))
Example 3: join method in python
flowers = [
"Daffodil",
"Evening Primrose",
"Hydrangea",
"Iris",
"Lavender",
"Sunflower",
"Tiger Lilly",
]
print(", ".join(flowers))
Example 4: python join
lst = ['a', 'b', 'c']
joinedLst = ', '.join(lst)
print(x)
Example 5: how to join strings in python
str1 = "Help"
str2 = "developers!"
print(str1 + ' ' + str2)