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 trial

Python

Garri Kats
Garri Kats
4,522 Points

Not entirely comprehending string formatting with dictionaries, or the challenge

What is another way to explain this challenge, it seems to be eluding me?

def favorite_food(name=None, food=None): return "Hi, I'm {name} and I love to eat {food}!".format(**dict)

dict = {"name": "Garri", "food": "RAMEN"}

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi there,

Are you able to link to the challenge you'e referring to? Are you getting any errrors or feedback about the values the code is returning?

It looks to me like you've simply got a function that receives 2 arguments, the values of which are returned to it by the dictionary with the name of dict.

So, rather than hard coding the values in your function, they receive them via the dictionary

Edit: Finally you'll want to print the message to the console with

print( favorite_food() );