Fix typos and make code example valid Python