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

Josh Long
Josh Long
605 Points

Not able to combine previously split(";") list with .join(", ")

I'm just trying to combine a .split(";") list together with .join(", "). Apparently the first task,

sundaes = available.split(";")

will not join the way I am asking it to. I suppose something to do with string and list differences, maybe the use of quotes... Hoping this is not a bug in the interface.

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

And why would task 1 (Line 2) be "no longer passing" if I haven't altered it?

5 Answers

Seth Kroger
Seth Kroger
56,413 Points

In most other languages you'd be correct but Python's join is reversed compared to others. It's join_string.join(list) instead of list.join(join_string)

display_menu = ", ".join(sundaes)
Josh Long
Josh Long
605 Points

Thanks Seth.

I want to say, "That doesn't look like anything to me" -- because even after the many hours of basic to intermediate Python I've been studying it still looks backwards. And I'm not really coming from another language.

But does that explain why task 1 is not passing? I kept going back to step one and nothing needed to change there.

Josh Long
Josh Long
605 Points

Is there anything in this code that was changed from version 2? I can't remember anything starting with quotes that didn't have parentheses around them.

I had similar problems, you have to copy the whole code from the last phase to all the previous phases, hopefully it will work then.

Josh Long
Josh Long
605 Points

Thanks Gyorgy, I got it to work -- wish I could explain how! But yeah, that is getting me sometimes, to leave the previous steps code unchanged when working on the current step.

I understand exactly what you mean Josh. It is confusing to see errors that imply that your previously correct code is wrong. Well...maybe it is not what is implied but as a beginner coder, I would not know any better!

I also find the join command quite weird, I think python is a intuitive language, and I would really have thought that this would be a more logical syntax: display_menu = sundaes.join(", ")