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 trialCheri Castro
226 PointsThe last step, in this challenge, is confusing to me. I don't really understand what it is I am supposed to do?
I was able to get through some other parts that had confused me before but now, I'm still stuck on this challenge, on what I think is the last step.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes=available.split(';')
menu="Our available flavors are: {}."
display_menu+", ".join(sundaes)
menu.format(display_menu)
2 Answers
K Cleveland
21,839 PointsCheck this out:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes=available.split(';')
menu="Our available flavors are: {}."
This is what you should have had after part 2 of the challenge, correct? Well, part 3 asks you to:
- Combine sundaes list into a variable named display menu
- Each item is rejoined together by (", ").
- Reassign menu variable to use existing variable
- You'll need to use .format() as well as display_menu
So, now you know some things you need to do:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes=available.split(';')
menu="Our available flavors are: {}." #should this line be here or somewhere else?
display_menu+", ".join(sundaes) # I think you have a typo here :)
menu.format(display_menu) #What are you formatting? Where's the place holder {}?
You're super close. Just need a bit of clean up. Good luck!
K Cleveland
21,839 PointsAh, OK. I understand now. So, my first piece of advice to you would be to work to understand what each piece of code does. So let's look at it!
# list that contains strings "green", "black", "silver"
my_favorite_colors = ["green", "black", "silver"]
# string "My favorite colors are "
my_string = "My favorite colors are "
# this last line is more complicated
# my_string = "My favorite colors are "
# ",".join(my_favorite_colors) will output "green, black, silver"
#So the full line becomes "My favorite colors are green, black, silver"
my_string + ", ".join(my_favorite_colors)
HOWEVER
The challenge asks you to combine the sundaes list into a new variable named display_menu
display_menu+", ".join(sundaes)
Here, you have an undefined variable that you're trying to combine together into a string. You should be creating a new variable called "display_menu". Next, combine the sundaes list using join, and assign it to the display_menu variable.
Finally, the challenge asks you to:
- reassign the menu variable to use the existing variable
- and .format() to replace the placeholder
- with the new string in display_menu.
So let me clear it up:
- Menu does not use the new variable (display_menu) you created. This is simply asking you to make sure menu is going to use display_menu.
- This is basically telling you to use .format() in your answer
- You created a new string and assigned it to the display_menu. This is basically saying: When you use .format(), make sure the thing you're trying to format is display_menu.
Hopefully this will clear up some things. Good luck!
Cheri Castro
226 PointsCheri Castro
226 PointsI'm not sure if that line should be somewhere else, it returned a passing result and allowed me to move on to the next step, which is the step that I'm on now. Ok, I'm not sure where the typo is... : / everything seems to be spelled correctly, I think. Unless, you are referring to the lack of parenthesis. In the example at the bottom of the video's page, it showed,
my_string+", ".join(my favorite colors)
So, perhaps I copied it down wrong. I kept having to switch back and forth between the video and the challenge because I couldn't remember exactly how everything was supposed to be typed out. So, I finally just wrote it down on a piece of paper that I could reference. I don't know what I'm formatting because of the wording of the last part, I don't really understand what is expected of me. The example given within the video, is as follows:
"My favorite flavors are: {}".format(", ").join(flavors))
The instructions in the last step seem to be asking us to do something a little different than what the video example showed us. I'm just plain confused with the last step.