缩短一个语句被反转的 if 语句

Shorten an if statement whose statement are reversed

我有以下情况:

string = "abc"
if (string[1] == "b" and string[2] == "c") or (string[1] == "c" and string[2] == "b"):
    print("ERROR")

有没有一种解决方案可以用 pythonic 方式缩短它? 我看到 (string[1] == "b" and string[2] == "c")(string[1] == "c" and string[2] == "b") 的反向语句。也许我可以使用它?

是否有解决方案以 pythonic 方式缩短它?

是的,在这里:

string = "abc"
if (string[1:3] == "bc") or (string[1:3] == "cb"):
    print("ERROR")

如果渴望更短的路 - if string[1:3] in ('bc', 'cb'):