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 Python Collections (2016, retired 2019) Dictionaries String Formatting with Dictionaries

Reese Lynn
Reese Lynn
974 Points

What is going on?

I am getting an error, "Expected favorite_food({'name': 'Michelangelo', 'food': 'PIZZA'}) to return "Hi, I'm Michelangelo and I love to eat PIZZA!", but got "Hi, I'm Me and I love to eat qwerty!""

and when I used '''name="Michelangelo", food="PIZZA''', i got an error saying to use garfield and lasagna.

When I used garfield and lasagna, I got an error saying I have to use 'name': 'Michelangelo', 'food': 'PIZZA'.

WHY IS THIS?

Is this an error?

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

2 Answers

Duc Bui
Duc Bui
14,546 Points
def favorite_food(dict):
    return "Hi, I'm {name} and I love to eat {food}!".format(**dict)
Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

It looks like you're passing in the wrong values to the dictionary. The Error is telling you that it's expecting particular values to pass the challenge, Michaelangelo, and PIZZA. Try putting those in and see if that passes! :-)