table = {} for i in range(0, len(sentence)**2): a = i / len(sentence) b = i % len(sentence) if not table.has_key(a): table[a] = {} table[a][b] = []