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

Trying to place ", ".join(sundaes) in the placeholder of menu

I don't understand how to put the joined list of sundaes ", ".join(sundaes) in the placeholder for menu. What am I doing wrong in this situation? I don't understand how to use .format() with the menu variable to adjust the placeholder. I feel this isn't challenging but I'm just missing something simple

Thanks

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)

all of your code is good except the last line in which you have to assign the string made by joining the items in the list sundaes to disaplay_menu which you can do like this display_menu =", ".join(sundaes) and then you have to use display_menu for the placeholder in menu which you can do like this menu=menu.format(display_menu)

1 Answer

Nick Gaudio
seal-mask
.a{fill-rule:evenodd;}techdegree
Nick Gaudio
Python Web Development Techdegree Student 2,133 Points

To further go along with what Diwakar said:

what you currently have for display menu prints out this: 'Our available flavors are: {}.banana split, hot fudge, cherry, malted, black and white'

your menu variable already has the curvy brackets "{}" inside of them so you don't need to type that again and it wouldn't appear inside the argument itself like that. All you need to do is pass in what you plan to format menu with. In this case it's ", ".join(sundaes)

so what you can easily do here is remove your curly brackets and instead of adding the string of ", ".join(sundaes) after menu you should just pass that as the argument for the format. i.e., display_menu = menu.format(", ".join(sundaes))

you were extremely close!

if you want to shorten the code and put the last two lines into one line you could do this:

menu = "Our available flavors are: {}.".format(", ".join(sundaes))

I hope that helped you!