Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from assignments import MaxSizeList # assumes "class MaxSizeList"
- # is in a script called "assignments.py"
- a = MaxSizeList(3)
- b = MaxSizeList(1)
- a.push("hey")
- a.push("hi")
- a.push("let's")
- a.push("go")
- b.push("hey")
- b.push("hi")
- b.push("let's")
- b.push("go")
- print(a.get_list())
- print(b.get_list())
- Output
- # ['hi', "let's", 'go']
- # ['go']
- class MaxSizeList(object):
- ls = []
- def __init__(self,mx):
- self.val = mx
- def push(self,st):
- self.ls.append(st)
- def get_list(self):
- while len(self.ls) != self.val:
- self.ls.pop(0)
- return self.ls
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement