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 trialhoward lawler
10,579 Pointsstring formatting with dictionaries
I'm getting the error: "What happened to string_factory"?
I can't figure out what the error even means.
dicts = [
{'name': 'Michelangelo',
'food': 'PIZZA'},
{'name': 'Garfield',
'food': 'lasanga'},
{'name': 'Walter',
'food': 'pancakes'},
{'name': 'Galactus',
'food': 'worlds'}
]
string = "Hi, I'm {name} and I love to eat {food}!"
def string_factory(dicts, string):
new_list = []
for items in dicts:
new_list.append(string.format(**d))
return new_list
3 Answers
Dan Johnson
40,533 PointsIt likely can't find string_factory because of a name error, referencing d before it's defined. I imagine you meant to put items there instead.
After you swap that out make sure your return is in the right code block and then you should be good to go.
howard lawler
10,579 Pointshere's a link to the challenge:
howard lawler
10,579 Pointsthanks!