-5

my function looks like this:

def factorial(x):
        result = 1
        for item in range(1,x+1):
            result *= item
        return result 

print [factorial(x) for x in range(0,6)]

I'd like to print every result on a new line - could somebody please show me how to do this, perhaps using list comprehension or a lambda function of some kind - I'm trying to get the hang of them, so it'd be just awesome ;)

Thanks in advance!

Tomek Sztuk
  • 69
  • 1
  • 1
  • 9

1 Answers1

-1

Should be just:

print '\n'.join([str(factorial(x)) for x in range(0, 6)])
Josh Kupershmidt
  • 2,540
  • 21
  • 30