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

Daesik Kim
Daesik Kim
5,422 Points

What do you mean by create a Challenge from the arguments? Cannot go further.

I guess I don't quite understand the question.

I don't know what to do after this.

crud.py
from models import Challenge


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

2 Answers

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,074 Points

You have to use the function ".create" so you can actually create a new instance of a "Challenge", and you have to assign the values that you have received as parameters to that newly created Challenge. You can do it like this:

from models import Challenge

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

I hope that helps a little bit

Wow, that is weird. I had the same code but with the lines separated it wouldn't parse...:

from models import Challenge

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

Does anyone know why that would be?