# Revision history [back]

### How to return a list from a recursive function?

Hello,

I am trying to make a recursive function that will return a list but I get a SyntaxError. Here is the code working so far (just an example):

def myfactorial(n): if n == 1: return 1 else: return n * myfactorial(n-1)

myfactorial(10)

I need to return something like this: [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]

I know that there is already a build in factorial function, I created this recursive function only as an example of what I am trying to get: a list. To return a list of all values of a given recursion, the steps of it...

### How to return a list from a recursive function?

Hello,

I am trying to make a recursive function that will return a list but I get a SyntaxError. Here is the code working so far (just an example):

def myfactorial(n): if n == 1: 1: return 1 else: else: return n * myfactorial(n-1)

myfactorial(10) myfactorial(10)

I need to return something like this: [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]

I know that there is already a build in factorial function, I created this recursive function only as an example of what I am trying to get: a list. To return a list of all values of a given recursion, the steps of it...

### How to return a list from a recursive function?

Hello,

I am trying to make a recursive function that will return a list but I get a SyntaxError. Here is the code working so far (just an example):

def myfactorial(n):
if n == 1:
return 1
else:
return n * myfactorial(n-1)myfactorial(n-1)
myfactorial(10)
myfactorial(10)

I need to return something like this: [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]

I know that there is already a build in factorial function, I created this recursive function only as an example of what I am trying to get: a list. To return a list of all values of a given recursion, the steps of it...

### How to return a list from a recursive function?

Hello,

I am trying to make a recursive function that will return a list but I get a SyntaxError. Here is the code working so far (just an example):

def myfactorial(n):
if n == 1:
return 1
else:
return n * myfactorial(n-1)

myfactorial(10)


I need to return something like this: [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]

I know that there is already a build in factorial function, I created this recursive function only as an example of what I am trying to get: a list. To return a list of all values of a given recursion, the steps of it...

[myfactorial(n) for n in range(1, 10)]

[1, 2, 6, 24, 120, 720, 5040, 40320, 362880]


Now, how to put it "inside" in the recursive function?