0
Please explain the following code.
import random class VagueList: def__init__(self,cont): self.cont=cont def__get item__(self,index): return self.cont[index+random.randint(-1,1) def__len__(self): return random.randint(0,len(self.cont)*2) vague_list=VagueList(["A","B","C","D","E"]) print(len(vague_list)) print(len(vague_list)) print(vague_list[2]) print(vague_list[2])
3 Respostas
0
Are you asking what it is doing or how it is doing it?
0
how it's doing ?
0
Python has many builtin methods that exist in a custom class whether you wrote them or not. This class is overwriting some of those actions forcing them to give incorrect results when the query is made.