- 1
I tried this code and got diff ans diff times i run it
import random class A: def __init__(self,a): self.a=a def __getitem__(self,i): return self.a[i+random.randint(-1,1)] def __len__(self): return random.randint(0,len(self.a)*2) s=A(["A","B","C","D","E"]) print(len(s)) print(len(s)) print(s[2]) print(s[2])
2 Answers
+ 7
Well, if you are using random -- what else did you expect? ;)
+ 2
thanks i didnt notice that. kinda noob or a beginner to python