Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Write a recursive function countdown(n) that shows and then Go!
Base case: n is 0. Recursive case: show n, then call with n minus 1.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Base case. When n == 0, show Go! and stop.
Recursive case. Show n, then call countdown(n - 1).
For countdown(5), the program shows and then Go!
Log in to join the discussion.
Loading…
With Standard, you also open 10 more problems, 2 Python labs and 1 extra course. Everything you have used here stays free, always.