I\'m trying to build a list of the first ten factorials
[1,1,2,6,24,120,720,5040,40320,362880]
using only list comprehension. Is that possible
You can use math.factorial():
import math [math.factorial(n) for n in range(10)]
Output:
>>> import math >>> >>> [math.factorial(n) for n in range(10)] [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]