“期望的声明”,但代码没有错吗?

问题描述 投票:-2回答:1

获得“预期的声明”其他:

我曾尝试用elif替换它,但不能解决问题,到目前为止,没有任何在线方法对我有所帮助。

enter image description here

如果我不输入任何其他搜索结果,应该只打印错误消息变量。

if Cmdbar() == "Help":
    os.system('cls')
    print(colored(logo, 'blue'))
    for ItemClassesx in ItemClasses:
        print(colored(ItemClassesx, 'green'))
    Cmdbar()


elif Cmdbar() == "Longswords":
   os.system('cls')
   print(colored(logo, 'blue'))
   for Longswordsx in Longswords:
    print(colored(Longswordsx, 'green'))
Cmdbar()

else:
print(error)
python pycharm
1个回答
-1
投票

其他块不能保持为空。它必须至少包含“ pass”。

'print(error)'行必须在else块内缩进。

还必须在小数点处缩进您的'Cmdbar()'。

© www.soinside.com 2019 - 2024. All rights reserved.