Solution Review: Return Numbers From n to 0
Solution: Use Iterator
In this problem, you only had to edit the
next method to include a reverse for loop;
in range(self.n, -1, -1) where
i is decremented once in every iteration. In line 11 of the code below, you append the value of
i to the list in every iteration and return the list at the end of the method. In lines 14 and 15, you can test your code by creating an instance of the MyRange class and calling the next method.