python中的语法错误。带=符号时出错

时间:2018-05-17 16:20:37

标签: python syntax

def InitialiseSudoku(): # this function is for initialisation of the sudoku function
                        cols = '0123456789ABCDEF'
                        rows = 'ABCDEFGHIJKLMNOP'

global coordinates
coordinates = represent(rows, cols)

global subgridlist
subgridlist = ([represent(rows, c) for c in cols] + [represent(r, cols) for r in rows] + [represent(rs, cs) for rs in

    subgrids = dict((s, [u for u in subgridlist if s in u]) for s in coordinates)
    global constraintpartners
    constraintpartners = dict((s, set(sum(subgrids[s], [])) - set([s])) for s in coordinates)
    global dictionary
    global value
    i = 0
    for s in coordinates:
        dictionary[s] = ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1']
        value[s] = input_list[i]
        prune_domain[s] = ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
        i = i + 1

这会在行上产生语法错误:

subgrids = dict((s, [u for u in subgridlist if s in u]) for s in coordinates)

具体错误是=符号

1 个答案:

答案 0 :(得分:0)

通常错误通常出现在错误列表之前(这是因为之前的行有效,直到期望特定的语法结构。

这似乎是这种情况的一个例子,在第9行你陈述

for rs in

但那不完整,应该是

for rs in <iterable/variable>

可迭代/变量是迭代的任何内容。