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 trialAlex Trost
6,270 PointsConfused on "Create a function named search_challenges"... can someone explain in plain english?
"Create a function named search_challenges that takes two arguments, name and language. Return all Challenges where the name field contains name argument and the language field is equal to the language argument. Use == for equality. You don't need boolean and or binary & for this, just put both conditions in your where()."
This lesson has continually felt like they're testing before they explain the item, or it's not super clear what is being requested. Can someone break this down in simpler english so that I have an idea of what I need to do? It's tough when info is being passed to me from imported modules that I don't have access to.
Thanks!
from models import Challenge
def create_challenge(name, language, steps=1):
Challenge.create(name=name,
language=language,
steps=steps)
1 Answer
Steven Parker
231,236 PointsThe task isn't asking you for anything you need to dig into the import for. The example shows a create operation performed on "Challenge", so you can expect that a select() would work on it also.
So if we break down the task:
- Create a function named
search_challenges
define a function - that takes two arguments, name and language name the arguments
- Return all
Challenge
sreturn
the result of performing a select() onChallenge
- where the name field contains name argument add a .where() with a .contains expression for the name
- and the language field is equal to the language argument do an equality test
- just put both conditions in your where(). separate the two tests with a comma
There's a little bit more to accessing the fields, but assuming you recall how to handle that you should be able to get it now.
Alex Trost
6,270 PointsAlex Trost
6,270 PointsThank you yet again, Steven! You continue to come to my assistance. I got it now that you've broken it down. It was the 'where the name field contains the name argument' part that I think was really throwing me for a while.