Nov-06-2021, 11:42 PM
This kind of "if clause" works ok.
I'm just wondering if (no pun intended) this is good practice when writing Python.
I'm just wondering if (no pun intended) this is good practice when writing Python.
sign = '-' if n < 0 else ''Normally, I would start with "if", but the above is actually more human readable and succinct.
if n < 0: sign = '-' else: sign = ''