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 trialLeo Marco Corpuz
18,975 PointsCreate_challenge function
How do you create the name,language, and steps with the Challenge model?
from models import Challenge
def create_challenge(name,language,steps=1):
2 Answers
Steven Parker
231,248 PointsUsing the technique demonstrated in the previous video, you can call the "create" method on the imported "Challenge", and pass it keyword arguments.
valeriuv
20,999 PointsI got stuck for awhile on this challenge too.
Basically, in the create method on the Challenge, you assign the parameters from the function to the model variables from the model we created in the previous challenge. It goes like this: Challenge.create(name=name, language=language, steps=steps)
Leo Marco Corpuz
18,975 PointsLeo Marco Corpuz
18,975 PointsI saw a post about this challenge and the student passed with setting the arguments to themselves (name=name) on the create() function, including the steps argument when itβs 1 by default.
Steven Parker
231,248 PointsSteven Parker
231,248 PointsExactly. An example of the "keyword arguments" I mentioned would be "
name=name
".Matthew Smith
3,083 PointsMatthew Smith
3,083 PointsThe problem with this particular challenge is that it involves working with the Challenge class from models. The video prior to this is about the diary.py app that the instructor is writing. For many of these challenges using the Challenge class, we don't have visibility into what the challenge class contains. We can look at the documentation for the peewee library, but there is a level of abstraction between that and this challenge.