3 ms·
The "I find a way to use list comprehensions for everything" Python programmer: def fact(n): return eval('*'.join([str(x+1) for x in xrange(n)] + ['1']
by samdk 17y ago
The "I find a way to use list comprehensions for everything" Python programmer:
def fact(n):
return eval('*'.join([str(x+1) for x in xrange(n)] + ['1']))
- pmiller2 17y agoHere's a better one (taken from http://code.activestate.com/recipes/67668/#c7 http://code.activestate.com/recipes/67668/#c7 ): f= lambda n: [[[j for j in (j*i,)][0] for i in range(2,n+1)][-1] for j in (1,)][0]