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

Challenge.create()

Why is it not possible to do Challenge.create(name, language, steps) instead of Challenge.create(name=name, language=language, steps=steps)?

2 Answers

Ari Misha
Ari Misha
19,323 Points

Hiya Renhe! You're very close. But the challenge is asking ya to give "steps" argument a default value of 1. This is how your code should look like:

from models import Challenge

def create_challenge(name, language, steps=1):
    Challenge.create(name=name, language=language, steps=steps)

Hi Ari,

Do you know why name is set to name, language is set to language, and steps is set to steps in the body of the function?

Ari Misha
Ari Misha
19,323 Points

Sure thing hun! See the attributes on the left side of the assignment operator "name", "language" and "steps", are the entries you created in your database. If you go to Challenge class which is a "Model" class, it takes 3 entries "name", "language", "steps". Now for the right side of the assignment operator, these inputs simply come from the user itself and we are capturing 'em and using 'em to create entries in our database, right? Also we defined default "steps" argument to be 1, which means if the user wont pass the "steps" argument , your model will take the default value of "1". I hope it helped. (: