Make the python example more pythonic

The Python code looked like it was written by a JavaScript or Lisp programmer, so I took the liberty of making it more pythonic in a couple of easy step. Each commit is a separate step in refactoring, with the commit messages explaining why the changes were introduced. Please let me know if you have any questions or are not sure about any of the changes.

There was also a bug in the original code. Unfortunately, I noticed it in the middle of refactoring, so it's fixed in the 4th commit. Basically x and y are swapped in the map lookup.