Since im fairly new to python and programming i have a question of a very basic nature. I want to make a iteration function and a recursive function that does this:
bounce(4)
4 3 2 1 0 1 2 3 4
I know it's propably very simple but any help would be appreciated.
My current code looks like this:
def bounce1(n):
if n==0:
print "0",
else:
print n,
bounce1(n-1)
def bounce2(n):
if n>=1:
bounce2(n-1)
print n
def bounce(n):
bounce1(n)
bounce2(n)
rangefunction will probably be useful to you. Did you know? You can give negative numbers torange's third parameter. - Kevinrange:f=lambda x:map(abs,range(-x,x+1)) [NEW LINE] for x in f(4):print x,- mbomb007