# create a class that has a __getitem__ methodclassA:def__getitem__(self,index):print('getitem',index)ifindex>10:raiseStopIteration# test __getitem__A()[0]A()[1]# iterate using a for loopforiinA():pass# iterate manuallyit=iter(A())try:whileTrue:next(it)exceptStopIteration:pass