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

Joining and splitting not working out well. I keep coming up with the wrong series of Sundaes and commas...

Talk through it if possible...

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

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,426 Points

The menu_display should not have the "menu +" in its definition. Once corrected, the missing step is use the format method on the string menu to fill in the "{}" placeholder.

menu = menu.format(menu_display)
Miranda Shipley Gonzales
Miranda Shipley Gonzales
222 Points

I'm struggling with similar challenge question. According to the helps I'm looking at and the lessons, my answers seemed to match. Where am I getting this code wrong?

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

[MOD: added ```python formatting -cf]

Chris Freeman
Chris Freeman
Treehouse Moderator 68,426 Points

Miranda, you are very close. Three items need fixing:

  • the join should use the string ", " (comma and space)
  • "available" is missing the "l"
  • .format() method need a period between the closing quote and the "format" method name

Post back if you need more help. Good luck!!!

Miranda Shipley Gonzales
Miranda Shipley Gonzales
222 Points

Oh My Goodness!!!! Thank you Chris!!! You cracked the code for me. I feel a little silly. Thank you for using an encouraging tone "you're close". So thankful to be able to move forward!!!