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 trialsidni ahmed
3,329 PointsCreate a function named create_challenge()
I have seen this code in another post and I trying to understand it. can someone please explain why we pass 3 functions and how this code is CRUD?
thanks
from models import Challenge
def create_challenge():
pass
def create_challenge(name, language, steps):
pass
def create_challenge(name, language, steps=1):
pass
def create_challenge(name, language, steps=1):
Challenge.create(
name=name,
language=language,
steps=steps)
3 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsThe code you posted is a step-by-step solution to the challenge. Each definition adds the next requirement of that Task. One would not normally code this way. In python, the last definition of an object takes precedence so the previous definitions are overwritten and only the last one is checked as the solution to the challenge.
Post back if you need more information.
sidni ahmed
3,329 PointsThanks Chris. You're the best. I wish one day I can be good like you in python :)
paul amato
2,707 PointsThank you Chris, this post helped. It was not clear to me that Challenge was a table to be updated.