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 trialBenjamin Bradshaw
3,208 Pointswhat am i doing wrong?
it says that the output needs to be a list. how is it not a list?
# 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!"]
template = "Hi, I'm {name} and I love to eat {food}!"
values = [{'name': 'Benjamin', 'food': 'PB&J sandwhiches'}, {'name': 'Heather', 'food': 'pasta'}, {'name': 'Chris', 'food': 'chips'}]
def string_factory(values):
new_list = []
for items in values:
new_template = template.format(**items)
final = new_list.append(new_template)
return final
1 Answer
Ryan Tiedemann
3,017 PointsHi, In regards to the output not being a list. The new_list.append() method actually doesn't return a value. Rather it just updates the list stored in the new_list variable.
As such, you don't need to set final = new_list.append. But rather you just need to return new_list
I hope this helps!
Regards