Just tooling around for my own amusement, and I want to use a lambda, because I feel like it. Can I replace this function with a lambda?
def isodd(number):
if (number%2 == 0):
return False
else:
return True
Elementary, yes. But I’m interested to know…
And if you don’t really need a function you can replace it even without a lambda. 🙂
by itself is an expression that evaluates to True or False. Or even plainer,
which you can simplify like so:
But if that’s readable or not is probably in the eye of the beholder.