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

Joe Towles
Joe Towles
4,012 Points

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,330 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,330 Points

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

sundaes = available.split(";")