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

Weiwei Peng
Weiwei Peng
1,218 Points

How to use the '.join()'?

I couldn't pass the task 3 of the code challenge. I think my code is correct but I got the message saying: Bummer! Did you use the '.join(",")'?

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

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey there,

Your code is correct, except you have a small typo (kind of). The challenges are very specific and picky. This part want you to join them with "a comma and a space (", "). You are just missing the space. So...

menu = "Our available flavors are: {}.".format(",".join(sundaes))

should be...

menu = "Our available flavors are: {}.".format(", ".join(sundaes))

Keep Coding! :dizzy:

Weiwei Peng
Weiwei Peng
1,218 Points

You are right. The challenges are very picky. I did miss a space out there. Thanks! One more thing, I have tried to put the code in another way: menu.format(", ".join(sundaes)). I tried it in the workspace and it worked just fine. But somehow the same code didn't work in the code challenge.