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

troy sincomb
troy sincomb
6,510 Points

There seems to be a bug in the problem. My answer works, but it won't go through in the "check work".

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

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

Hi, I think you forgot the part of the problem that says to use the .format() in the menu string.

This code that I used worked:

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

Hope it helps

Sorry for the formatting....

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

sundaes = available.split(';')

display_menu = ", ".join(sundaes)

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

1 Answer

Ryan S
Ryan S
27,276 Points

Hi Troy,

The wording in task 3 can be a bit confusing, but it is looking for the final answer as the "menu" variable. As you have it now, you are trying to assign the final completed string to "display_menu". As with a lot of these challenges, your logic may work outside of the challenge, but inside they are often looking for very specific things. Here, it is specifically checking for the value of the "menu" variable.

Also, you will need to remove the parentheses around the string ", " to which the .join() method is applied. For some reason the challenge won't accept them, even though it should work outside of the challenge. You don't actually need them anyways.

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.

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

Hope this helps.