focus on the AND condition ... return is true only if both conditions are true so unless the factorial is calculated (second portion of AND statement) return will not give factorial. the second portion is recursive call to self as long as x is greater than 1
On Wed, Oct 27, 2010 at 11:55 AM, Geobird <a1chan...@gmail.com> wrote: > > I am a beginner in Python and would ask for a help. > > > I was searching for smaller version of code to calculate > factorial . Found this one > def fact(x): > return x > 1 and x * fact(x - 1) or 1 > > But I don't really get how ( ....x > 1 and x * fact(x - 1)....) > works . > -- > http://mail.python.org/mailman/listinfo/python-list > -- Nitin Pawar
-- http://mail.python.org/mailman/listinfo/python-list