In this exercise, the task is to write a function that picks a random word from a list of words from the SOWPODS dictionary. Download this file and save it in the same directory as your Python code. This file is Peter Norvig’s compilation of the dictionary of words used in professional Scrabble tournaments. Each line in the file contains a single word.
Hint: use the Python
random library for picking a random word.
To solve this exercise, you need to do three things:
Here is a sample solution:
Here is an alternate approach, with some comments:
There are many solutions to every problem. Enjoy hacking around to find another solution!comments powered by Disqus