Working through Project Euler in Python (again)