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

Landon Hansen
Landon Hansen
346 Points

I don't know where I went wrong in this question. I ran all the code through python 3.51 and it didn't have any error?

display_menu. = menu.format(", ".join(sundaes)) This is the final line of code that I got and like I said I ran it through python and it worked perfectly and gave me a string that looked right. Please explain what they are looking for and how to get it the way they want me to. I am on my second day of coding ever and the help would be awesome. Thanks in advance :)

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

2 Answers

andren
andren
28,558 Points

For your second day of coding your code is quite impressive, this challenge is somewhat infamous for frustrating quite a large amount of users due to it's instructions being pretty confusing, so I don't blame you for being uncertain about what the challenge wants.

This challenge actually has two different intended solutions, one which requires using the display_menu and one which doesn't, your code is actually very close to the solution that does not require the display_menu variable.

If you remove the display_menu variable (which has a typo in it by the way, in the form of a period right after the variable name) and instead use the format method directly on the string you assign to the method variable like this:

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

Then your code will pass. As what this challenge is ultimately looking for is to have a formatted menu stored in the menu variable.

The other intended solution for this challenge looks like this:

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

That solution performs the same work as the other solution but splits the joining of the sundaes and the formatting of the menu into separate steps.

Harriet Ryder
Harriet Ryder
16,885 Points

I think you have ended up with a full stop in there by accident. Check your final line - a full stop cannot be valid syntax as part of a variable name!