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

Alex Figueroa
Alex Figueroa
2,148 Points

I've been stuck in this question for a few days and cannot seem to find an answer. Would you be able to assist me?

what am I supposed to enter in between .join()? Is it .join('sundaes')

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

1 Answer

Billy Bellchambers
Billy Bellchambers
21,689 Points

Hi Alex,

The task is asking for the list sundaes to be joined using a string of ', '. To achieve this you first need to declare the string and follow it with the join keyword with the list in brackets.

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

display_menu = ', '.join(sundaes)

This joins up the items in sundaes using a comma and a space to separate. Once joined we can then use the .format() function to plug this string into our menu using the place holder {}.

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)

Hope this helps with your python challenge.

Happy Coding!

Alex Figueroa
Alex Figueroa
2,148 Points

Thanks Billy. I'm just starting and I was doing well until I hit this road block. I appreciate it.

-AF