Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Lists and Concatenating Strings

Give Feedback

Creating strings from a list of words is something you will do frequently when writing Python code. This lesson showed you how to create strings using str.join().

words = ['cat', 'dog', 'horse', 'human']
print ' '.join(words)

This will print each word contained in words separated by a space.

Comments & Discussion

gracebr28 on June 4, 2019

Shouldn’t the print_strings_good function be like this? def print_strings_good (strings): print (‘ ‘.join(strings)) #use input instead

Instead of the list name, .join should pass the name of the function input (strings in this case) instead, so that when we call the function we can print any list that we want.

Become a Member to join the conversation.