0

A doubt in this attached code !!

I'm unable to understand the output of the code. https://code.sololearn.com/cnaFH1zCuojl/?ref=app

2nd Jun 2019, 5:48 PM
thiru
3 Réponses
+ 3
Well, it basicall works on random choices to print outputs. Actually, a class vague_list was made with 3 functions, dont forget your initialization. The first function prints the length of the list but on a random note. The dunder(magic method) __len__ gets called whenever a len function is used e.g class Lists... def __len__: return len(Lists) print(len(Lists(a,b,c,d))) The result is 4. The dunder for indexing a list is __getItem__ NOTE: The code works on random choice, so the outputs are not true. Also, the code I wrote here has some errors. Just ignore them I hope you understand
2nd Jun 2019, 6:36 PM
xpan
xpan - avatar
+ 3
You welcome bro.
2nd Jun 2019, 6:43 PM
xpan
xpan - avatar
+ 1
Got it dude and thanks
2nd Jun 2019, 6:39 PM
thiru