I cannot use the following statement because x
and y
may be defined as None
:
if x*y > 9:
pass
unsupported operand type(s) for *: 'NoneType' and 'NoneType'
So I should check first for the existence:
if x and y:
if x*y > 9:
pass
It seems a bit redundant. Is there a better way to achieve this?