+ 1
Pls. explain why this syntax answer is 8
class asdf: def __init__(self,x): self.x = x def __setitem__(self,y,z): print(y + z) x = asdf([1,2,3,4]) x[4]=4
1 Respuesta
+ 3
class asdf:
def __init__(self,x):
self.x = x
def __setitem__(self,y,z):
print(y + z) #4 + 4
x = asdf([1,2,3,4])
x[4]=4 #x[y] = z --> print(y + z) --> print(4 + 4) --> print(8)