def get_random_word(dictionary, starting_letter=None):
    """
    Takes the dictionary to read from and returns a random word
    optionally accepts a starting letter
    """
    if starting_letter is None:
        starting_letter = random.choice(list(dictionary.keys()))

    try:
        to_return = random.choice(dictionary[starting_letter])
    except KeyError:
        msg = "Dictionary does not contain a word starting with '{}'"
        raise NoWordForLetter(msg.format(starting_letter))

    return to_return
def get_random_word ( dictionary , starting_letter = None ) : if starting_letter is None : starting_letter = random . choice ( list ( dictionary . keys ( ) ) ) try : to_return = random . choice ( dictionary [ starting_letter ] ) except KeyError : msg = "Dictionary does not contain a word starting with '{}'" raise NoWordForLetter ( msg . format ( starting_letter ) ) return to_return
Takes the dictionary to read from and returns a random word
    optionally accepts a starting letter