Lambda函数中if语句的语法错误

当我尝试定义时:

getter = lambda x: listofIndices.append(index(x)) if x == targetScore

我收到错误声明:

getter = lambda x: listofIndices.append(index(x)) if x == targetScore                                                                   
SyntaxError: invalid syntax
评论