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

mustafa attaie
mustafa attaie
8,068 Points

stuck on challenge task 3 of 3 in Python basics

I've made it this far but this last challenge I'm not understanding. This last lesson feels like gibberish to me still. If someone could help me in showing me how to finish task 3 and maybe explaining it step by step? I'd greatly appreciate it!

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

sundaes = available.split(";")

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

1 Answer

Joel Bardsley
Joel Bardsley
31,247 Points

Hi Mustafa, I'll try my best to explain for you:

Firstly, as the menu variable has placeholder braces within it, you need to add the .format() string method to the end of it as you’ve done in previous challenges. All you need to do now is work out what you pass into .format().

Ok, so you already know that the .split() method separates a string into a list of items. Think of .join() as doing the opposite, So if you enter a string that you wish to join each sundae flavor by (in this case a comma and a space) you can do that by simply doing:

, .join(sundaes)

Lastly, remember that you can put function calls inside another function call and you should have your answer.

Hopefully that’s been slightly less gibberish! Joel