Question OOP-CLS-0012
MediumWhat is the output of this code?
class Bag:
items = []
def add(self, x):
self.items.append(x)
a = Bag()
b = Bag()
a.add(1)
b.add(2)
print(a.items, b.items)
- A.
[1, 2] [1, 2]
- B.
[] [1, 2]
- C.
[1] [2]
- D.
[1, 2] []
Sign up free to see the answer and a step-by-step explanation.