>>> def solution(lst):
... dex = len(lst) - 1
... while dex >= 0:
... yield lst[dex]
... dex -= 1
...
>>> nums = solution([1, 2, 3, 4])
>>> next(nums)
4
>>> next(nums)
3
>>> next(nums)
2
>>> next(nums)
1
>>> next(nums)
Traceback (most recent call last):
File "<input>", line 1, in <module>
StopIteration