python中IF-else语句的else上出现语法错误

python中IF-else语句的else上出现语法错误,python,if-statement,python-3.x,syntax-error,Python,If Statement,Python 3.x,Syntax Error,我总是在这个特定的“else”上遇到语法错误。我不知道是什么问题。如果还不够清楚,那就是第16行的else。我几天前刚开始学习python。所以,请不要太用力地面对手掌 W = 1 while W == 1: if MH > 0: PlayerInput = input("Attack, Defend, or Run('1','2',or'3'):") if PlayerInput == "3": W = 0

我总是在这个特定的“else”上遇到语法错误。我不知道是什么问题。如果还不够清楚,那就是第16行的else。我几天前刚开始学习python。所以,请不要太用力地面对手掌

W = 1
while W == 1:
    if MH > 0:
        PlayerInput = input("Attack, Defend, or Run('1','2',or'3'):")
        if PlayerInput == "3":
            W = 0
        elif PlayerInput == "1": #Attack
            Atk = randint(1,4)
            if Atk == 1:
                Atk = randint(1,4)
                if Atk == 1:
                    print ("Miss")
                else:
                    MH = MH-((1/2)*FightingAbility)        
                    print ("Enemy lost %s Health" % ((1/2)*FightingAbility)
            else:<<<<---------[[This else is giving me trouble]]
                MH = MH-Fightingability
                print ("Enemy lost %s Health" % (FightingAbility))
        elif PlayerInput == "2": #Defend   
            if S > FightingAbility: #Enemy is stronger
                Def = randint(1,4)
                if Def == 1:
                    Def = randint(1,4)
                    if Def == 1:
                        print ("The %s Missed" % (E))
                    else:
                        Health = Health-((1/2)*S)        
                        print ("You lost %s Health" % ((1/2)*S)
                else:
                    Health = Health-S
                    print ("You lost %s Health" % (S))
            elif S <= FightingAbility: #Enemy is weaker
                Def = randint(1,4)
                if Def == 1:
                    Def = randint(1,4)
                    if Def == 1:
                        Health = Health-S
                        print ("You lost %s Health" % (S))
                    else:
                        Health = Health-((1/2)*S)        
                        print ("You lost %s Health" % ((1/2)*S)
                else:
                    print ("The %s Missed" % (E))
    else:
        Win=1
        pass
W=1
当W==1时:
如果MH>0:
PlayerInput=输入(“攻击、防御或奔跑('1'、'2'或'3'):”)
如果PlayerInput==“3”:
W=0
elif PlayerInput==“1”:#攻击
Atk=randint(1,4)
如果Atk==1:
Atk=randint(1,4)
如果Atk==1:
打印(“未打印”)
其他:
MH=MH-((1/2)*作战能力)
打印(“敌人失去%s生命值”((1/2)*战斗能力)
else:
print
行(在
else
之前)没有右括号

print ("Enemy lost %s Health" % ((1/2)*FightingAbility)

我相信你已经被否决了,因为你提供了一个简短的代码示例。在发布到S.O之前,你应该将代码简化为存在问题的最简单的形式。在这种情况下,这样做可能会帮助你自己解决问题。