python - Boolean evaluation in a lambda -
Just tooling around for your own entertainment, and I want to use lambda, because I think so. Can I change this function with lambda? DEF isodd (number): if (number% 2 == 0): Returned wrong other: Back right
Primary, yes. But I am interested to know ...
And if you do not actually need a function lambda Without it, you can also change it :)
(number% 2! = 0)
The self is an expression that evaluates for right or wrong is. Or even normal,
bool (number% 2)
which you can do so simple:
If number% 2: print "Odd!" Other: Print "Even!"
But if it is readable or is probably not in view of the viewer.
Comments
Post a Comment