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 trialEswar Ambati
890 PointsI am not sure what to do?
I am not sure what to do because I thought I had unpacked a dictionary but obviously I didn't. I am a bit confused
def favorite_food(dict):
if dict:
return "Hi, I'm {name} and I love to eat {food}!".format()
else:
print("Hi what is ur name and what food would you like to eat?")
favorite_food(**{"dict": {"name": "Kenneth", "food": "tacos"}})
2 Answers
Steven Parker
231,236 PointsYou're overthinking this a bit. You won't need to add a conditional statement. In fact, the only thing you need to add is to pass an argument to the "format" function in the provided code. That's the place where you can use the unpacking operator with the "dict" parameter.
Jenn Chu
Courses Plus Student 18,400 PointsTry this:
def favorite_food(dict):
return "Hi, I'm {name} and I love to eat {food}!".format(**dict)
Steven Parker
231,236 PointsFYI: Explicit answers without any explanation are strongly discouraged by Treehouse and may be subject to redaction by staff or moderators.