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

Rakesh Bharadwaj
Rakesh Bharadwaj
1,376 Points

Unable to perform this task

Getting no clue on how to perform this

string_factory.py
# Example:
# values = [{"name": "Michelangelo", "food": "PIZZA"}, {"name": "Garfield", "food": "lasagna"}]
# string_factory(values)
# ["Hi, I'm Michelangelo and I love to eat PIZZA!", "Hi, I'm Garfield and I love to eat lasagna!"]

def sting_factory(lists):
    template = "Hi, I'm {name} and I love to eat {food}!"
    a = lists[0]
    b = lists[1]
    return template.format(name,food)

Your first issue is the misspelling of string in string_factory without this being spelled right, the code that the challenge uses to test your own code will not be able to even try to do its job. Another thing is that the challenge requires you to return a list containing both strings, but in your code, you are only attempting to return a single string. I would also add in that format has no context of what name and food are at this point because you haven't unpacked their values into the string template like the challenge wants you to do. If you need additional guidance on this, it might be good to rewatch the video before the challenge that talks about this specifically, but I can offer a more direct answer if you still need help afterward. I wouldn't be doing you any favors by solving the challenge for you :)