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])

1st Mar 2017, 12:29 PM
Pragya Priya
Pragya Priya - avatar
3 Respuestas
0
Are you asking what it is doing or how it is doing it?
3rd Mar 2017, 7:59 PM
Kevin Gilkey-Graham
Kevin Gilkey-Graham - avatar
0
how it's doing ?
3rd Mar 2017, 8:03 PM
Pragya Priya
Pragya Priya - avatar
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.
3rd Mar 2017, 8:30 PM
Kevin Gilkey-Graham
Kevin Gilkey-Graham - avatar