words = ["zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"]
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
number_to_word = dict(zip(numbers, words))
word_to_number = dict(zip(words, numbers))
The rest, of course, can remain the same. I think adding this would also help to show how Python idioms like zip can help simplify code.That said, I still voted the submission up. I've seen several articles like this which point out how people use new languages in the same braindead way they used their old languages, yet I feel this one featured a very simple example with a paradigm that maps well to Python.
EDIT: Whoops, I got distracted and didn't realize that I didn't finish reading the article. It turns out that the approach is modified later on to do something even better, but I'll leave you to check out the article for that.