0

I have a program that adjusts some values when an input is negative. Those values cannot be grouped for various reasons (I cannot put them all into one nice if statement).

This is a code example:

if num > 0:
    n_op = 50
else:
    n_op = -50

OR

n_op = 50
if num < 0:
    n_op = -50 (OR) n_op= -n_op

Pieces like this happen everywhere in my code and I am starting to get sick of it. Not only it doesn't seem like the most efficient solution, they also make the code look like crap.

Is there a way to make those specific pieces of code nicer?

0 Answers0