python sloučit do seznamu string
>>> sentence = ['this','is','a','sentence']
>>> '-'.join(sentence)
'this-is-a-sentence'
join() python
# example of join() function in python
numList = ['1', '2', '3', '4']
separator = ', '
print(separator.join(numList))
připojte metody v pythonu
# the join method in python is works like
# it joins the the string that you provide to it to a sequence types(lists etc..)
flowers = [
"Daffodil",
"Evening Primrose",
"Hydrangea",
"Iris",
"Lavender",
"Sunflower",
"Tiger Lilly",
]
print(", ".join(flowers))
# what the sbove code does is it joins all the flowers in list by ', '
# output = Daffodil, Evening Primrose, Hydrangea, Iris, Lavender, Sunflower, Tiger Lilly
N
"seperator".join(list/tuple)
python string: .join()
# Мөрийн арга .join() нь мөрүүдийн жагсаалтыг хооронд нь холбож, хүссэн хязгаарлагчтай холбосон шинэ мөр үүсгэнэ.
# .join() аргыг хязгаарлагч дээр ажиллуулж, нэгтгэх мөрийн массивыг аргумент болгон дамжуулдаг.
x = "-".join(["Codecademy", "is", "awesome"])
print(x)
# Prints: Codecademy-is-awesome
připojte se k funkci v pythonu
# use of join function to join list
# elements without any separator.
# Joining with empty separator
list1 = ['g','e','e','k', 's']
print("".join(list1))
#Output:
geeks
jak se připojit řetězce v pythonu
str1 = "Help"
str2 = "developers!"
print(str1 + ' ' + str2)
python připojit
# Joins all items in a list or tuple, using a specific separator
lst = ['a', 'b', 'c']
joinedLst = ', '.join(lst)
print(x) # Prints 'a, b, c'