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

Heath Kirchner
Heath Kirchner
613 Points

Not sure how to get task 3 of 3 of .split() and .join() to work. Would help if there were examples to work off of.

Everytime I attempt to do this task, and get it wrong, I have to start over becasue task 1 will no longer solve. I am not sure what I am doing because the video did not really cover this and there are no examples to look over.

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

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

1 Answer

Chase Marchione
Chase Marchione
155,055 Points

Hi Heath,

You're halfway there. The challenge wants us to add this new string information onto the menu variable's current value. Thus:

available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}".format(', '.join(sundaes))
  • The sundaes variable is used as an argument that is passed to the join method.
  • The format method is used to specify how we want the text to be formatted (we're telling the format method "hey, replace that {} placeholder with our sundaes, and separate each one with a comma and a space.")

Hope this helps!