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

Jaime Jesus Guerra Torres
Jaime Jesus Guerra Torres
16,954 Points

Can't solve this step, it seems to have a bug

i know i use correctly the split() and the join() functions but it doesn't let me pass

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

sundaes = available.split(";")

menu = "Our available flavors are: {}."

display_menu = sundaes.join(", ")

menu = menu.format(display_menu)

3 Answers

andren
andren
28,558 Points

Actually you aren't using the split and join functions correctly, well the split function is in fact correct, but the join function is not.

The join function is a bit counter intuitive, instead of calling it on the thing you want to join and passing in the join string like you'd expect, you actually have to do the opposite. You call the join function on the string you want to use to join and then pass in the array as an argument. Like this:

display_menu = ", ".join(sundaes)

It's a bit confusing, but in Python the join method format is string.join(list) where the leading string is what you're using as the glue to hold your final string together. If you switch your join around to match this format, you'll be fine :)