我一直在这个特定的“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