Im trying to subtract with prefixes as objects.
Here is my code
class Prefix: def __init__(self, m=0, cm=0): self.m = m self.cm = cm def __sub__(self, other): centim = self.cm - other.cm meter = (self.m - other.m) - abs(centim/100) if meter < 1: centim = m*100 meter = 0 return Prefix(meter, cm)
Im trying to subtract in a way which creates a negative centimeter value and take 1m from the meter object such that this is fulfilled
Prefix(2, 20) - Prefix(1, 30) == Prefix(0, 90)