Skip to main content
Crowdfunding
Python + AI for Geeks
Practice

Using the join() Function to Concatenate Strings

The join() function is used to concatenate multiple strings into one.

It connects elements of an iterable object like strings, lists, tuples, etc., using a specific delimiter.

Using the join function
'delimiter'.join(iterable_object)

Examples of Using join()

The join() function takes an iterable that includes strings as a parameter (input required to execute the function).

This function inserts the specified delimiter between each element of the string, joining them into a single string.

join function example
words = ['Enjoyable', 'Python', 'Programming']
sentence = ' '.join(words)

print("sentence:", sentence)
# "Enjoyable Python Programming"

The join() function is useful for concatenating multiple strings into one or converting a list or tuple into a string.

Converting a list to a string
words = ['apple', 'banana', 'cherry', 'date', 'fig']
word_joined = ', '.join(words)

print("word_joined:", word_joined)

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.