recursion, Python, countup, countdown

Viewed 9332

I am supposed to write a recursive function counting(5) that prints 5 4 3 2 1 0 1 2 3 4 5.
I have made two functions down below that do half part each but I need them to be put together.

def countdown(n):
    if n == 0:
        print 0
    else:
        print n,
        countdown(n-1)

def countup(n):
    if n >= 1:
        countup(n - 1)
        print n,
3 Answers
Related