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 trialPitrov Secondary
5,121 PointsI am confused, I do not clearly understand what I need to do here, and I do not know how I can get it right, I need help
I am doing this challenge and I am not sure what I have to do. Can you help me?
def favorite_food(name=None, food=None):
return "Hi, I'm {name} and I love to eat {food}!".format(name, food)
favorite_food(**{'name': 'Michelangelo', 'food': 'PIZZA'})
1 Answer
Bruce Röttgers
18,211 PointsHey, you need to rewrite the function, so that it fills in name with the value of the key name (and food) of the dictionary.
You have rewritten the function declaration, which you aren't allowed to do in the challenge. The function should accept a dictionary and your job is to pull out the values and insert them in the print statement using the format() function.
Pitrov Secondary
5,121 PointsPitrov Secondary
5,121 PointsI do not understand... I can't get it to work. here's what I got
Bruce Röttgers
18,211 PointsBruce Röttgers
18,211 PointsYou shouldn't call the function, that often breaks the challenge. Delete the function call and try again.
Pitrov Secondary
5,121 PointsPitrov Secondary
5,121 PointsSo I need to do the challenge without calling the function? So I just needed to paste in what he already had written, I tried that, but that didn't work either. Sorry if the solution is obvious, cause I have no idea.
Bruce Röttgers
18,211 PointsBruce Röttgers
18,211 PointsNo, my bad I messed up. You need to insert the appropriate values in the format function, (value for key in dictionary)
Pitrov Secondary
5,121 PointsPitrov Secondary
5,121 PointsI changed my code a little bit, and now I do not see what is wrong with it. Here's what I've got
Bruce Röttgers
18,211 PointsBruce Röttgers
18,211 PointsYOURE NOT ALLOWED TO CHANGE THE FUNCTION PARAMETERS
Pitrov Secondary
5,121 PointsPitrov Secondary
5,121 PointsI am sorry...
Pitrov Secondary
5,121 PointsPitrov Secondary
5,121 Pointshere is what I've got now.
What is wrong with this code?