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

Aysha Ayala
Aysha Ayala
496 Points

concatenate?

I'm not sure what to join and what to format and how to type it out.

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

Thank you so much I have been working on this for days! I know I need to problem solve and trouble shoot, this was my brick wall.

2 Answers

Ashikur Rahman
seal-mask
.a{fill-rule:evenodd;}techdegree
Ashikur Rahman
Python Web Development Techdegree Student 932 Points

Here is your solution

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

Just paste it to figure out this step. Don't forgot to understand the code

Steven Parker
Steven Parker
229,732 Points

Actually, you are supposed to explain the code you post. Treehouse discourages posting of code answers without explanations.

Ashikur Rahman
seal-mask
.a{fill-rule:evenodd;}techdegree
Ashikur Rahman
Python Web Development Techdegree Student 932 Points

Kenneth explained enough thought, isn't it? actually some time it's difficult to find out or build a logic for beginner. But no one wouldn't like to stack with a step. You should move even slowly and day by day brain will absorb automatically upon practice. Ignore it if I'm not right. Thanks

Steven Parker
Steven Parker
229,732 Points

Working out the answer for yourself using some hints actually helps most people learn better than just getting the final answer. "Understand the code" is not an effective learning technique for many people.

Steven Parker
Steven Parker
229,732 Points

You've got most of the parts there but the order needs a bit of work.

The join method is applied to a string (you got that right), but it should take the list as the argument. Then, that whole thing should be the argument to format, which would be applied to the template (which is in menu). The result goes back into menu.

You can do all that on a single line, or split it up and use display_menu as the halfway-done value.

I'll bet you can get it now without a spoiler.