pastebin

Paste Search Dynamic
Recent pastes
ArrayList
  1. class ArrayList:
  2.    def __init__(self, number_list):
  3.        self.numbers = number_list
  4.    def __iter__(self):
  5.        self.pos = 0
  6.        return self
  7.    def __next__(self):
  8.        if(self.pos < len(self.numbers)):
  9.            self.pos += 1
  10.            return self.numbers[self.pos - 1]
  11.        else:
  12.            raise stopiteration
  13. array_obj = ArrayList([1, 2, 3])
  14. it = iter(array_obj)
  15. print(next(it)) #output: 2
  16. print(next(it)) #output: 3
  17. print(next(it))
  18.  
Parsed in 0.004 seconds