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 trialRwiddhi Chakraborty
2,447 PointsSearch databases
I'm pretty confused what the question asks of me. Why do I need a '==' when I can use contains()? Also, what do they mean by "name field contains name argument"? Thanks for helping out.
from models import Challenge
def create_challenge(name, language, steps=1):
Challenge.create(name=name,
language=language,
steps=steps)
def search_challenges(name,language):
entries = Challenge.select()
for entry in entries:
return entry.where(Challenge.name==name)
return entry.where(Challenge.language==language)
1 Answer
Kourosh Raeen
23,733 PointsYou need to use contanis() for name but == for language. You also don't need a loop. By the name field they mean the name field in the database, and by the name argument they mean the name argument passed into the function. You should also have only one return statement. Try this:
from models import Challenge
def create_challenge(name, language, steps=1):
Challenge.create(name=name,
language=language,
steps=steps)
def search_challenges(name, language):
return Challenge.select().where(Challenge.name.contains(name), Challenge.language == language)