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

why is this incorrect

not sure what I'm doing wrong here, thanks for any help

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

2 Answers

You are soooo close! You just mixed up display_menu and menu.

Try this:

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

EDIT: You also used the join function incorrectly. You must call the .join() method on the separator string, then pass in the list to the split method. It's strange, but you kinda have to get used to it.

Also, I just noticed that you have an extra period after the {} in display_menu's string. Code challenges are super-picky and won't even except that to pass. Keep this in mind!


I hope this helps. ~Alex

Don't forget to mark this answer as a Best answer if it helped you out! Thanks!

Stuart Wright
Stuart Wright
41,119 Points

When using the join method, the string you would like to use to separate the items goes first, then the list goes in brackets. So play_menu = ", ".join(sundaes) should give you the desired result.

You will also need to make sure you assign a value to variable display_menu before printing it (i.e. your 4th line should come before your 3rd).

Edit to add: Alex beat me to it, I agree with his solution.