dimanche 27 septembre 2020

Using an if else statement inside a for statement inside lambda statement

So i know that this work :

fac = lambda x: [element for element in x]

and this also work :

fac = lambda x: x*fac(x-1) if x!=0 else 1

but why this is not working :

fac = lambda *x :  [ n * fac(n-1) if n!=0 else 1 for n in x]

i have an infinite loop.

Aucun commentaire:

Enregistrer un commentaire