Syntax error on the else of an IF-ELSE statement in python -
i keep getting syntax error on 1 specific "else". have no idea problem is. if it's not clear enough already, it's else on line 16. started python few days ago. so, don't face palm hard please.
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 giving me trouble]] mh = mh-fightingability print ("enemy lost %s health" % (fightingability)) elif playerinput == "2": #defend if s > fightingability: #enemy 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 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
print
line (before else
) not have closing parenthesis.
print ("enemy lost %s health" % ((1/2)*fightingability)
Comments
Post a Comment