I have a class called Polynomial, and it stores information to the polynomial in a dictionary. The keys are the exponents and the values are the coefficients. To create an instance of the Polynomial class, you type the following:
P1 = Polynomial((2, 14), (2, 11), (-12, 3), (42, 0))
The first item in the pairing is the coefficient, and the second item is the exponent.
The initialization looks like this:
class Polynomial:
def __init__(self, *termpairs):
termdict = dict(termpairs)
self.termdict = {}
for x, y in termdict.items():
self.termdict[y] = x
Now if I have two coefficients that are the same, for example ((2, 14), (2, 11)), It will only create a dictionary for one of them like so:
{11: 2}
Im not sure why the one pairing is not showing up. Any thoughts?