All challenges
Code AnalysisIntermediate 45s

dunder getitem (Analysis)

What is the output?
Starter code
class Box:
    def __init__(self, items):
        self.items = items
    def __getitem__(self, i):
        return self.items[i] * 2

b = Box([1, 2, 3])
print(b[2])

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle