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

Sean Kochel
Sean Kochel
1,693 Points

Assistance using .split and .join in Python Basics

I tried the code displayed in this post. I also tried adding my .join after my .split. My logic is as follows:

create variable available create variable sundaes by splitting available at each semi-colon create a new sundaes variable by joining the old sundaes variable with a ", " update the menu given the new sundaes variable.

It keeps telling me that my code is breaking Task 1

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

sundaes = available.split(";")

sundaes = sundaes.join(", ")

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

1 Answer

Hi there, you are using .split() correctly, however, .join() should be used on the string you want to join the list with and the list should go inside the brackets. Switch them around and you should be good to go! Also, the additional assignment of sundaes is not needed since you can directly format it in as a joined string:

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

sundaes = available.split(";")

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

If you have any further questions, please leave a comment :)

Thanks,

Haider