Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Python Data Types Splitting and Joining

Hello!

I am not understanding this lesson. I tried re-watching the video several times but still have not grasp the concept of splitting and joining. Also, when I try o right in my code it gives me an error syntax. Here is my code:>>> My favorite flavors are: " + ', '.join(flavors)
File "<stdin>", line 1
My favorite flavors are: " + ', '.join(flavors)
^
SyntaxError: invalid syntax

"My favorite flavors are : {}.format(", ".join(flavors))
File "<stdin>", line 1
"My favorite flavors are : {}.format(", ".join(flavors))

On Python shell it points to my error but when i try to correct it still gives me an error.

2 Answers

AJ Salmon
AJ Salmon
5,675 Points

Hi Wilfried! When using .format(), the function goes outside of the string you're formatting. Example:

>>> "Formatting can be {}!".format('tricky')
>>> 'Formatting can be tricky!'

Notice how the parentheses are closed before .format() is called. Hopefully this clears your issue up! I see nothing wrong with your use of the .join() method :)

Kelsey Carolan
Kelsey Carolan
4,447 Points

Hi Wilfried,

It looks like you are missing the period and end quotation (.") after your closing curly brace. Otherwise, everything else looks good!

"My favorite flavors are: {}.".format(", ".join(flavors))