我是Python的新手,我正在尝试使用具有这种格式的三元opertor(我想是这样)
value_true if <test> else value_false
Run Code Online (Sandbox Code Playgroud)
这是一段代码:
expanded = set()
while not someExpression:
continue if currentState in expanded else expanded.push(currentState)
# some code here
Run Code Online (Sandbox Code Playgroud)
但Python不喜欢它并说:
SyntaxError: invalid syntax (pointed to if)
Run Code Online (Sandbox Code Playgroud)
怎么解决?