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 Using Databases in Python Gettin' CRUD-y With It CRUD: Create Function

Rabih Atallah
Rabih Atallah
3,405 Points

What is missing in my code?

The question is to create a Challenge with the function's parameter as the attributes

crud.py
from models import Challenge
def create_challenge(name, language, steps = 1):
  Challenge.create(name = 'rabih', language = 'english', steps = 1)

1 Answer

Dan Johnson
Dan Johnson
40,532 Points

The arguments being passed into create should be assigned the values that were passed in to the create_challenge function.

Rabih Atallah
Rabih Atallah
3,405 Points

and now it's still not working: from models import Challenge def create_challenge(name, language, steps = 1): Challenge.create(name = "Ruby", language = "Booleans", steps) pass

Dan Johnson
Dan Johnson
40,532 Points

That's still hard wiring in literals. It looks strange, but you can do stuff like name = name when dealing with the inner call to the create method.