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 trialDerek G
806 PointsIS there a trick that I am missing?
I think I am combining these correctly, however. The machine says different. Am I not understanding the question?
Combine sundaes list? I think this does that?
Jeffery Austin
8,128 PointsFor some reason the attach code feature isn't working so you'll have to copy and paste your code so we can see your code.
1 Answer
Nathan Tallack
22,160 PointsYeah, this one was a little confusing. I helped someone else with this yesterday.
Consider my code below.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}."
menu = menu.format(", ".join(sundaes))
First we make the sundaes variable which is a list of strings made up of all the words split on the ; character.
Then we make a variable named menu which is our string with the braces placeholder in it to use with the format method later.
Then we overwrite our menu variable with the string formatted (so that means what is inside the format argument will be placed where the braces are) and that argument is the result of the join method.
Join is a little confusing for me. But I worked out that you call join on a string that you want to be between the things you are joining. In this case we are putting a commer and a space so the string ", " is what we are calling .join on and I pass in the sundaes list to that.
So the end result would be the big long string for menu which reads:
"Our available flavors are: banana split, hot fudge, cherry, malted, black and white."
jag
18,266 Pointsjag
18,266 PointsProviding your code would be helpful.