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()

What am I doing wrong?

I am not exactly sure how to reassign my menu variable.

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

3 Answers

Thank you. I was also wondering how the problem could be solved without adding an extra line of code, I got this far:

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

I am currently getting an error...

Chris Freeman
Chris Freeman
Treehouse Moderator 68,426 Points

The failure is caused by using an assignment statement in the format arguments.

Remove the assignment and it will pass. Explicitly assigning display_menu is not required to pass the challenge:

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

Thank you!

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,426 Points

You are close! Two items to fix:

:point_right: the join is a string method, so it is called on the "glue string" used to join the item in the listed argument.

 ', '.join(sundaes)

:point_right: The format needs to use the display_menu and not the sundaes list.

available = "banana split;hot fudge;cherry;malted;black and white"

sundaes = available.split(';')

menu = "our available flavors are: {}.".format("display_menu")

display_menu = ", ".join("sundaes")

I tried this, but I am getting an error: Bummer! Did you use ", ".join()?

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

Chris Freeman
Chris Freeman
Treehouse Moderator 68,426 Points

You are much closer. The arguments to join and format should not be in quote because they are variable names. By using quotes they are seems as simple strings.

Removing the quotes causes a new problem: display_menu is referenced before it is assigned. Swap the last two lines so display_menu is defined before it is used in the format method.