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 trialTravis John Villanueva
5,052 PointsIt works fine in the workspace-dont know what is the problem
Hi I tested my code via workspace and im stuck with this problem. I dont know how to debug it as it is working fine? Do you think its a bug?
d = dict(name="Travis", food="PIZZA")
def favorite_food(name,food):
return "Hi, I'm {} and I love to eat {}!".format(name,food)
print(favorite_food(**d))
3 Answers
Steven Parker
231,269 PointsHere's a few hints:
- don't change the function definition. It should still take a single (dictionary) argument
- you don't need to define anything before the function
- you just need to provide values to the "format" by unpacking the dictionary
- you won't need to "print" anything
Jason Sikes
Courses Plus Student 10,202 PointsTo give a little more help if you still haven't got it:
- Just as Steven Parker stated - "don't change the function definition."
- But you will have to add to this function.
- Steven Parker also stated - "you just need to provide values to the "format" by unpacking the dictionary"
- Stop and think how to get a value from a keyword in a dictionary. Hint: test_dict["a"] - Example show to us by Kenneth Love, returns the value 3.
- The keyword was ["a"] that held the value of 3, while test_dict is the name of the dictionary that holds the keyword and value.
- Now, Travis John Villanueva stated - "Little did I know that the commentary above the problem serve as a clue."
- The placeholders are a keyword, they just need a value assigned to them.
Thanks, Steven Parker and Travis John Villanueva for not giving the answer but helping us all stop and think to help with our learning. Never stop trying. It will come to you.
Steven Parker
231,269 PointsJason — if you start getting a lot of spam email, you might want to replace that live email link with a partly obfuscated reference so spam-bots won't recognize it.
Travis John Villanueva
5,052 PointsNo Worries Steven! :)
Travis John Villanueva
5,052 PointsTravis John Villanueva
5,052 PointsHi Steven Parker, Thank you for the reply. I spend the whole day figuring out how to unpack a dictionary by creating a function then im going to call that inside the favorite_food function. Little did i know that the commentary above the problem serve as a clue.