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 trialNadine Abella
1,032 Pointsmaximum recursion depth exceeded
why do I get an a maximum recursion error when nothing in my scripts is even recursive?
from models import Challenge
def create_challenge(names,languages,step= 1):
Challenge.create(name = names,
language = languages)
create_challenge("ruby","python")
3 Answers
karis hutcheson
7,036 PointsOkay, so what he meant was that when a user calls your create_challenge function, they should not have to specify a steps argument and, if they don't, it will default to 1. Which is what you did. However, steps still needs to be passed in to create the entry. It will only default to one unless the user specifies otherwise. Here's how I solved it:
def create_challenge(new_name,new_language,new_steps=1):
Challenge.create(name = new_name, language = new_language, steps=new_steps)
karis hutcheson
7,036 PointsIt looks like your function call at the end of the code block is indented, making the function infinitely recursive.
def create_challenge(names,languages,step= 1):
Challenge.create(name = names,
language = languages)
create_challenge("ruby","python") # de-indent this line
Nadine Abella
1,032 Pointsright right. like seriously I thought that was already de-dented. anyway thank you!
karis hutcheson
7,036 Pointsno prob! :)
Nadine Abella
1,032 Pointsfrom models import Challenge
def create_challenge(names,languages,step=1):
Challenge.create(name = names, language = languages)
create_challenge("ruby","python")
karis hutcheson it still gives me an error
Didn't find the challenge I asked you to create.
whats wrong?
karis hutcheson
7,036 PointsDo you need to pass in the steps argument to the Challenge.create() function? I.E.
Challenge.create(name = names, language = languages, steps = step)
Nadine Abella
1,032 Pointssteps is optional. I don't know what's wrong shouldn't it be right? and the only time i remember steps is when it was used by to sort the the data from the database not when it will be created so it's very confusing
karis hutcheson
7,036 PointsI'm going to go back and do this exercise again. I'll get back to you in a minute...
Nadine Abella
1,032 Pointsok thank you. I'm been stuck on this for quite a while now
Nadine Abella
1,032 PointsNadine Abella
1,032 Pointsthank you very much. I don't know sometimes to me the instructions are kinda vague? maybe that's just me. or maybe the variable names are clashing with something. anyway thank you
karis hutcheson
7,036 Pointskaris hutcheson
7,036 PointsNo prob :) I'm running into some of that vagueness in Java. On the plus side, I'm getting a pretty freakin' good brain workout.