class Coefficients: def __init__(self, coef): self.coef = [coef] def __add__(self, other, new): if len(self.coef) < len(other.coef): for i in range(len(self.coef)): new.coef += (self.coef[i] + other.coef[i]) for i in range(len(self.coef),len(other.coef)): new.coef += other.coef[i] else: for i in range(len(other)): new.coef += (self.coef[i] + other.coef[i]) for i in range(len(other.coef),len(self.coef)): new.ceof += self.coef[i] return Coefficients(new) a = Coefficients([2, 0, 4, -1, 0, 6]) b = Coefficients([-1, -3, 0, 4.5]) c = a + b print(c)
TypeError: Coefficients.__add__() missing 1 required positional argument: ‘new’
I’m not particularly sure where to go from here
submitted by /u/PFKM
[link] [comments]
r/learnpython class Coefficients: def __init__(self, coef): self.coef = [coef] def __add__(self, other, new): if len(self.coef) < len(other.coef): for i in range(len(self.coef)): new.coef += (self.coef[i] + other.coef[i]) for i in range(len(self.coef),len(other.coef)): new.coef += other.coef[i] else: for i in range(len(other)): new.coef += (self.coef[i] + other.coef[i]) for i in range(len(other.coef),len(self.coef)): new.ceof += self.coef[i] return Coefficients(new) a = Coefficients([2, 0, 4, -1, 0, 6]) b = Coefficients([-1, -3, 0, 4.5]) c = a + b print(c) TypeError: Coefficients.__add__() missing 1 required positional argument: ‘new’ I’m not particularly sure where to go from here submitted by /u/PFKM [link] [comments]
class Coefficients: def __init__(self, coef): self.coef = [coef] def __add__(self, other, new): if len(self.coef) < len(other.coef): for i in range(len(self.coef)): new.coef += (self.coef[i] + other.coef[i]) for i in range(len(self.coef),len(other.coef)): new.coef += other.coef[i] else: for i in range(len(other)): new.coef += (self.coef[i] + other.coef[i]) for i in range(len(other.coef),len(self.coef)): new.ceof += self.coef[i] return Coefficients(new) a = Coefficients([2, 0, 4, -1, 0, 6]) b = Coefficients([-1, -3, 0, 4.5]) c = a + b print(c)
TypeError: Coefficients.__add__() missing 1 required positional argument: ‘new’
I’m not particularly sure where to go from here
submitted by /u/PFKM
[link] [comments]