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

create Challenge

Hey guys,

I'm having some trouble understanding what this task is asking for. I especially don't understand the create the challenge part. Should it be part of the function.

Thanks for your help!

crud.py
from models import Challenge

name = 'Yey'
language = 'Python'
steps = 1

def create_challenge(name, language, steps):
  pass

challenge = Challenge(name, language, steps)

2 Answers

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Jose!

The main issue I see it that you are trying to create the challenge outside the function and this is not what we want! The function itself is called create_challenge, so what we want is to put the piece of code that creates the challenge, inside that function.

Let's have a look at the code itself: The def line you wrote is very close to the right one, you only need to set the default steps equal to 1. Inside the function you need to use the Challenge.create() method, passing in the parameters of the function.

Let me know if more help is needed, but I think you are pretty close and can do it!

;) Vittorio

Thanks Vittorio!