From the course: Python: Recursion

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Challenge: Fix the recursive algorithm

Challenge: Fix the recursive algorithm - Python Tutorial

From the course: Python: Recursion

Start my 1-month free trial

Challenge: Fix the recursive algorithm

(upbeat music) - [Instructor] All right then, are you ready to test your skills? We have a challenge for you for this chapter. We have a program here, a turtle graphics program. And when I run it, you'll see that there's a problem. And the problem is that our turtle doesn't fully understand the three laws of recursion. Okay, so you need to think back to what the three laws of recursion are, and I'll just remind you what they are. They're having a base case, having movement towards the base case, and having the recursive call itself. Now you can see here on line 14 that the third law has actually been met because we have our recursive call. Draw spiral is being called within the function definition of draw spiral. So that's good. But we don't have a base case and we don't have movements towards the base case. Now, the base case, you can use the maximum length that we've defined at the top here as a constant. So…

Contents