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

7th Dec 2017, 6:20 PM
Arif
2 Respuestas
+ 7
Well, if you are using random -- what else did you expect? ;)
7th Dec 2017, 6:57 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
thanks i didnt notice that. kinda noob or a beginner to python
7th Dec 2017, 7:42 PM
Arif