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 Use .split() and .join()

Jan Lundeen
Jan Lundeen
5,887 Points

Challenge Task 3 of 3 - Combining sundaes list into a new variable and rejoin it - Task 1 is no longer passing

Hi,

Okay, I'm still working on Challenge 3. It asks me to combine the sundaes list into a new variable and rejoin it together using a comma and a space. I copied the question and my answer below. The first 3 lines work, but I get an error on the 4th line. Not sure what is happening. I put a # in front of my comments. Any ideas?

Thanks,

Jan

Alright, let's finish making our menu. Combine the sundaes list into a new variable named display_menu, where each item in the list is rejoined together by a comma and a space (", "). Then use .format() on our existing menu variable to replace the placeholder with the new string in display_menu.

If you're really brave, you can even accomplish this all on the same line where menu is currently being set.

available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}."
# Lines 1-3 work.  
display_menu = "Our available flavors are: {}.format(",".join.menu)
#I got another "Oops! It looks like Task 1 is no longer passing" again.

====================================================

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.format(",".join.menu)
display_menu = "Our available flavors are: {}.format(",".join.menu)

[MOD: added ```python formatting -cf]

Jan Lundeen
Jan Lundeen
5,887 Points

Chris, you are right. It was. I must be dyslexic:).

Thanks,

Jan

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

The format and join syntax is in correct:

available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}".format(", ".join(sundaes))
display_menu = "Our available flavors are: {}".format(", ".join(sundaes))
Jan Lundeen
Jan Lundeen
5,887 Points

Hi Chris,

I tried your suggestion, but I got the error Bummer! Did you use .join(", ")?

I reviewed what I entered and it looks like I entered your answer verbatim. Can you help me out with this?

Thanks,

Jan

Chris Freeman
Chris Freeman
Treehouse Moderator 68,457 Points

The error is saying there a space needed after the comma in the join string.

Jan Lundeen
Jan Lundeen
5,887 Points

Thanks Chris! That worked. Is that a standard error in python for spaces? It doesn't indicate where the space is needed. Perhaps it's something you figure out after using python enough.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,457 Points

The needed space was based on the task description which asked for the space.