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

victor E
victor E
19,145 Points

I Believe I can use the format option but I am not sure if I understand the question correctly or not

I am stuck on this part. I would like to see what the correct way of using this variable is, and the why behind it. thank you

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes= available.split(",")
menu= 'our available flavors are: {}'
display_menu= sundaes.format(', ')
James J. McCombie
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
James J. McCombie
Python Web Development Techdegree Graduate 21,199 Points

Hello,

sundaes = available.split(';') for the second statement.

it asks you to make display_menu by joining the sundaes list of strings by ", "

Then you can pass this as an argument for format, called on the existing string menu.

James

1 Answer

Ronit Mankad
Ronit Mankad
12,166 Points

Hi Victor, you have 2 errors here, First: You have to split available at ';'. So sundaes = available.split(";") Second: Sundaes will be a list. So you can't do display_menu = sundaes.format(", ") You have to use the join function: display_menu = ", ".join(sundaes) and then use format to add it to menu.

Try yourself. Here's my code for reference:

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

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