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

What am I doing wrong?

I have looked at different answers online where people are having issues with this problem as well. It keeps saying Bummer! string_factory() missing 1 required positional argument: 'string'. I am stuck and I have tried everything I can think of. Its most likely something small but like I said others have been having this issue as well and I'm getting frustrated lol. PLEASE HELP!

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!"]

dicts = [
    {'name': 'Michelangelo',
     'food': 'PIZZA'},
    {'name': 'Garfield',
     'food': 'lasanga'},

]

string = "Hi, I'm {name} and I love to eat {food}!"

def string_factory(dicts, string):
    string_list = []

    for dict in dicts:
        string_list.append(string.format(**dict))

    return string_list

1 Answer

Pete P
Pete P
7,613 Points

I believe the function string_factory should only take one argument - the list of dictionaries. No need to include 'string' as an argument and no need to define the 'dicts' yourself. The only code you need to write is the function string_factory. Looks to me like your code will work once you fix the above.

def string_factory(dicts):

    #  Your code here

    return string_list