Jan-02-2021, 06:10 AM
(This post was last modified: Jan-02-2021, 06:10 AM by Gribouillis.)
The only unpythonic parts that I see here are
if i==0 & j==0
which should be if not(i or j)
and i==0|j==0
which should be not(i and j)
. Note that & and | are bitwise operators and not logical operators. The result is also different because they have different levels of operator precedence. For example >>> 0==0 & 7==0 True >>> 0==0 and 7==0 FalseWriting code on a single line does not necessarily give better Python code, and it is not necessarily 'pythonic'. I'm not sure there is a better solution here.