Add Python 2 compatibility

I don't think this will work - `max()` raises ValueError if you give it an empty sequence.