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

hi i am having some difficulty in completing challenge Task 3 of 3 (banana.py). can anyone offer their help please?

many thanks

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

2 Answers

Vidhya Sagar
Vidhya Sagar
1,568 Points

Hi michael. The thing is you are using the syntax for join wrongly. It is not the same way as split. In join if you want to join a list seperated by a comma then you will have to write ans=",".join(input). And another problem with you're code is that they have asked you to reassign menu and not available. Try it on your own. I have also added my code below for you're reference.

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

Thank you for your swift and comprehensive response. Kind Regards

Mic

If you want to go the "really brave" route and accomplish the goal all on the same line where menu is currently set, you can do this:

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