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

Tim Ngwena
Tim Ngwena
4,824 Points

Why is the following wrong in this ecercise, it works in console and is it not what the question is asking?

The question fails as you can see in this screenshot: http://imgur.com/a/YVqBH however run the same thing in console and it works and i think this is what the question is asking. >> http://imgur.com/a/gS1Zg

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

Read the directions carefully... 1."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 (", ")" 2."Then reassign the menu variable to use the existing variable and .format()" You're on the right track, and yes your code will output the correct string, but you're not exactly doing what he asks.

Great job though, I hope I helped without giving you the answer

2 Answers

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

you are not doing exactly what the challenge is asking for. the final answer should be assigned to menu, not display_menu. display_menu is an intermediate step.

Tim Ngwena
Tim Ngwena
4,824 Points

Okay maybe just my misinterpartion of it as the ask for the "brave" solution doesn't come across as a requirement. Thanks for your help.

Jake Salo
Jake Salo
13,175 Points

Yeah, try formatting the string using the same variable, like this:

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

This is what I did to move on. :)