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 trialsowmya c
6,966 Pointscrdu creating a function
create a function create_challenge that will take name language and steps as arguments.steps is equal to 1.create a Challenge class what is wrong with my code
from models import Challenge
from peewee import *
db = SqliteDatabase()
def create_challenge(name, language, steps):
steps = 1
class Challenge(Model):
name = TextField()
language = TextField()
class Meta:
database = db
if __name__ == '__main__':
db.connect()
1 Answer
Ryan Kriegbaum
16,180 PointsYou are changing the value of 'steps' to 1 within the function, not assigning it as a default / fail safe value when the value is being passed into the function.
from models import Challenge
def create_challenge(name, language, steps='default value goes here'):
Hope that helps