Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Sample:
- def __init__(self):
- self.contents = {}
- def insert(self, item):
- self.contents[item] = self.contents.get(item, 0) + 1
- def erase_one(self, item):
- if item in self.contents:
- del self.contents[item]
- def erase_many(self, matchCriteria):
- tempDict = self.contents.copy()
- for currentItem in tempDict:
- if currentItem == matchCriteria:
- self.erase_one(currentItem)
- def list_items(self):
- for currentItem in self.contents:
- print currentItem
- test = Sample()
- test.insert(1)
- test.insert(1)
- test.insert(2)
- test.erase_many(1)
- test.list_items()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement