fork(2) download
  1. class Stack:
  2. def __init__(self):
  3. self.__data = []
  4.  
  5. def empty(self):
  6. return len(self.__data) == 0
  7.  
  8. def size(self):
  9. return len(self.__data)
  10.  
  11. def push(self, x):
  12. self.__data.append(x)
  13.  
  14. def pop(self):
  15. return self.__data.pop()
  16.  
  17. stack = Stack()
  18. stack.push(10)
  19. stack.push(15)
  20. stack.push(20)
  21.  
  22. print(stack.empty())
  23. print(stack.size())
  24. print(stack.pop())
  25. print(stack.pop())
  26. print(stack.pop())
  27. print(stack.empty())
  28. print(stack.size())
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
False
3
20
15
10
True
0