Psst! Check what courses we have in our offer, and get them all here to save $727. Act fast–this deal is available only 3/14–3/21.
Quick recap
7. The join() function
Indexing and slicing


Another interesting technique is to use join():

visited_countries = ['Norway', 'Sweden', 'Denmark', 'Germany', 'France']
separator = ', '
print('I have visited the following countries: ' + separator.join(visited_countries))

The code above will show:

I have visited the following countries: Norway, Sweden, Denmark, Germany, France


creates a string that contains all the elements of visited_countries separated by the separator. Note that there is no separator after the last element in the list.


Join all path parts in the template with backslash signs (\) and print the entire string.

Remember—to access a backslash sign in Python, you need to write: '\\'

Stuck? Here's a hint!

Use '\\'.join(path_parts).