use list.reverse() instead of reversed for Python 3 compatibility