Python忽略if / else命令?

时间:2016-07-27 22:07:37

标签: python if-statement python-3.5

python if / else命令完全无效。

import time
import os
import sys

def zelphaMain():
    def zelphaMain_Credits():
        print("Coding:")
        print("John Antonio Anselmo")
        print("")
        print("")
        print(">>Back")
        def zelphaMain_CreditsInput_Options():
            zelphaMain_CreditsInput = input(">> ")
            if zelphaMain_CreditsInput == ("back") or ("Back"):
                os.system('cls')
                zelphaMain()
            else:
                print("What you have entered is not a valid command")
                zelphaMain_CreditsInput_Options()
        zelphaMain_CreditsInput_Options()

    def zelphaMain_Game():
        print("*")
        time.sleep(1)
        print("*")
        time.sleep(1)
        print("*")
        time.sleep(1)
        os.system('cls')
        time.sleep(1)
        print("Zelpha808")
        time.sleep(1)
        print("")
        print("Booting...")
        time.sleep(8)
        os.system('cls')
    def zelphaMain_Menu():
        print("Main Menu")
        print("")
        print("")
        print("Welcome to Zelpha808")
        print("")
        print("")
        print(">>Start")
        print(">>Credits")
        print("")
        zelphaMain_MenuInput = input(">> ")
        if zelphaMain_MenuInput == ("Credits") or ("credits"):
            zelphaMain_Credits()
        else:
            exit()

    zelphaMain_Menu()

zelphaMain()

当我运行程序时,如果zelphaMain_MenuInput == ("Credits") or ("credits"):,并进入游戏的主菜单,无论我输入什么,程序都会转到zelphaMain_Credits()。并且在学分中,无论我输入什么,它就像我输入“返回”一样。我不知道发生了什么,如果你们中的任何人感到困惑或需要澄清,我很乐意添加更多细节。

1 个答案:

答案 0 :(得分:1)

if zelphaMain_MenuInput == ("Credits") or zelphaMain_MenuInput == ("credits"):