Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Python Data Types Use .split() and .join()

Task three is not working for me. When I run it in a Python shell it works. Is there a problem with this task?

also I don't know how you can complete the last sentence of task three on the same line.

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

2 Answers

Hello there,

It looks like the task is asking you to print out the display_menu rather than sundaes, which means you'll need to declare that on the line before 'menu', and then switch it out in the 'menu' definition. That would look something like this:

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)

The shorter solution, though, is to do the join on the same line as menu, like the challenge says. You mentioned being curious about how to do that - basically, it's just skipping the display_menu variable altogether, and performing the join right on the menu line, inside .format. That looks like this, and should also pass:

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

Hope this helps!

Thank you for your response it was very helpful.