made reverse.py more Pythonic