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

I cannot get challenge task three of three at all. I do not even know where to begin.

the wording for the question is throwing me off.

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

3 Answers

Mujibur Rahman
Mujibur Rahman
1,658 Points

I can't remember what task 3 was, but looking at your code I can see a few problems.

line 4: sundae is not defined, you variable is called sundaes not sundae, so use the correct variable name.

line 5: display is not defined, I'm assuming your trying to print display_menu, if that's the case, you should write: print(display_menu).

Heya, I added some comments to the code below that will hopefully help you understand :)

available = "banana split;hot fudge;cherry;malted;black and white"
# here we split the string into a list at each ';' character
sundaes = available.split(';')
# then re-join the list into a string placing a comma and space(', ') between each list item
display_menu = ', '.join(sundaes)
# now use our new string to print a nicely formatted menu
menu = "Our available flavors are: {}.".format(display_menu)

Keep at it!

Mujibur Rahman
Mujibur Rahman
1,658 Points

available = "banana split;hot fudge;cherry;malted;black and white"

sundaes = available.split(";")