def build_successors_table(tokens):
    "Return a dictionary: keys are words; values are lists of successors.\n\n    >>> text = ['We', 'came', 'to', 'investigate', ',', 'catch', 'bad', 'guys', 'and', 'to', 'eat', 'pie', '.']\n    >>> table = build_successors_table(text)\n    >>> sorted(table)\n    [',', '.', 'We', 'and', 'bad', 'came', 'catch', 'eat', 'guys', 'investigate', 'pie', 'to']\n    >>> table['to']\n    ['investigate', 'eat']\n    >>> table['pie']\n    ['.']\n    >>> table['.']\n    ['We']\n    "
    table = {}
    prev = '.'
    for word in tokens:
        if (prev not in table):
            '*** YOUR CODE HERE ***'
        '*** YOUR CODE HERE ***'
        prev = word
    return table
Return a dictionary: keys are words; values are lists of successors.

>>> text = ['We', 'came', 'to', 'investigate', ',', 'catch', 'bad', 'guys', 'and', 'to', 'eat', 'pie', '.']
>>> table = build_successors_table(text)
>>> sorted(table)
[',', '.', 'We', 'and', 'bad', 'came', 'catch', 'eat', 'guys', 'investigate', 'pie', 'to']
>>> table['to']
['investigate', 'eat']
>>> table['pie']
['.']
>>> table['.']
['We']
def build_successors_table(tokens):
    "Return a dictionary: keys are words; values are lists of successors.\n\n    >>> text = ['We', 'came', 'to', 'investigate', ',', 'catch', 'bad', 'guys', 'and', 'to', 'eat', 'pie', '.']\n    >>> table = build_successors_table(text)\n    >>> sorted(table)\n    [',', '.', 'We', 'and', 'bad', 'came', 'catch', 'eat', 'guys', 'investigate', 'pie', 'to']\n    >>> table['to']\n    ['investigate', 'eat']\n    >>> table['pie']\n    ['.']\n    >>> table['.']\n    ['We']\n    "
    table = {}
    prev = '.'
    for word in tokens:
        if (prev not in table):
            '*** YOUR CODE HERE ***'
        '*** YOUR CODE HERE ***'
        prev = word
    return table