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

Patrik Karlsson
PLUS
Patrik Karlsson
Courses Plus Student 436 Points

I'm stuck. How do i use .join and .split at the same time?

I've looked at the video several times now but i don't understand how i join the string and split it at the same time.

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
avaialble + "banana split;hot fudge;cherry;malted;black and white".split(";").join(sundaes)

1 Answer

Thomas Fildes
Thomas Fildes
22,687 Points

Hi Patrik,

Please see the code I used to pass this challenge below:

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

sundaes = available.split(";")

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

I am not sure why you want to use split and join on the same line because task 3 doesn't ask you to do this. I have looked for resources for using split and join on the same line and found nothing so I am not sure you can do this.

Hope this helps! Happy Coding!!!

Patrik Karlsson
Patrik Karlsson
Courses Plus Student 436 Points

Thanks i clearly miss understood the challenge. And i probably should've asked for help way sooner. The coding would be much happier that way :)

Thomas Fildes
Thomas Fildes
22,687 Points

Yeah it is important to spend time on solving the problem but when stuck for a while there will always be someone who has ran into the same problem who can help you. I am a prime example of that :) because this challenge was a nightmare for me months ago. Keep at it Patrik!