Feb-20-2019, 10:10 PM
It's all a big mess. The error you are getting is because GroceryList() calls GroceryList.__init__, which specifies three parameters: self, item, and price. The self parameter is provided automatically, but you don't provide an item and price parameter. There are a number of ways you could fix that, but you still have other problems.
But
You need to create an attribute that holds the dictionary, probably called prices. I wouldn't start with an item and a price, that doesn't make sense. Then none of the other methods should be class methods. They should all operate on the attribute with the dictionary (self.prices if you called it prices), not on self directly.
But
self = {}
is just invalid, even if it doesn't cause an error. self refers to the current instance the method is working on. You have just obliterated that, and replaced it with an empty dictionary. That dictionary will just disappear at the end of the method call.You need to create an attribute that holds the dictionary, probably called prices. I wouldn't start with an item and a price, that doesn't make sense. Then none of the other methods should be class methods. They should all operate on the attribute with the dictionary (self.prices if you called it prices), not on self directly.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures