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