Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 90,705 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! :-)