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.

Parth Pandya
678 PointsError: string_factory() missing 1 required positional argument: 'template', but works in IDE
Heres my code, I keep getting the error mentioned in the title:
dicts = [ {'name': 'Michelangelo', 'food': 'PIZZA'}, {'name': 'Garfield', 'food': 'lasanga'}, {'name': 'Walter', 'food': 'pancakes'}, {'name': 'Galactus', 'food': 'worlds'} ]
template = "Hi, I'm {name} and I love to eat {food}!"
def string_factory(dicts, template): strings = [] for items in dicts: strings.append(template.format(**items)) return strings
string_factory(dicts, template)

frankgenova
Python Web Development Techdegree Student 15,592 Pointstemplate is a global variable established outside of the loop, I don't think you have to pass it to the routine, however I'm not sure that is what the issue is
1 Answer

Steven Parker
220,513 PointsYou should only take one argument.
The instructions say to write a function "that accepts a list of dictionaries as an argument". But your function requires a list of dictionaries and a template. You'll make use of the global template in your function, you won't get one as an argument.
And just define your function. Don't also call it (or define your own list of dicts).
frankgenova
Python Web Development Techdegree Student 15,592 Pointsfrankgenova
Python Web Development Techdegree Student 15,592 PointsParth Try posting in markdown, the instructions are in the hyperlink below the posting window. It will look like this.