Paul Rubin <http://phr...@nospam.invalid> writes: > I'd write nested functions: > > def fact(n): > if n < 0: raise ValueError > def f1(n): > return 1 if n==0 else n*f1(n-1) > return f1(n)
I forgot to add: all these versions except your original one should add a type check if you are trying to program defensively. Otherwise they can recurse infinitely if you give a positive non-integer arg like fact(3.5). -- http://mail.python.org/mailman/listinfo/python-list