Resolved: Can you please provide some examples of using the range methods?
Like get_item, reversed etc.
1 answers ( 1 marked as helpful)
Hi Panagiotis!
Thanks for reaching out.
An example for the reversed() method:
my_list = [1, 5, 10, 2]
for n in reversed(my_list):
print(n)
An example for the getitem() method:
class MyList:
def __init__(self, data):
self.data = data
def __getitem__(self, index):
return self.data[index]
my_list = MyList([1, 2, 3, 4, 5])
print(my_list[0])
Hope this helps.
Best,
Tsvetelin