IN
class ListCount():
def __init__(self, *args):
self.list = [x for x in args]
self.count = {}.fromkey(range(len(arg)), 0) #fromkey(key, value)
def __len__(self):
return len(self.list)
def __getitem__(self, item):
self.count[item] += 1
peint(self.list[item])
return self.list[item]
c1 = ListCount(1, 3, 5, 7, 9)
c1[1]
print(c1.__len__())
print(c1.count)
OUT
3
5
{0: 0, 1: 1, 2: 0, 3: 0, 4: 0}