python 3.x - E901, or TokenError: EOF in multi-line statement on repl.it -


i have been coding on website called https://repl.it. pep8 returning error @ last line:

e901, or tokenerror: eof in multi-line statement`. 

i've tried rewriting section, redoing indents, , renaming variables.

-edit- i've checked indentations , if statements, here new code. still pulling same issues. note not @ code , won't understand mean right of bat. try add comments code.

from random import randint time import sleep advlist = ["crawl", "walk", "run", "sprint"] atklist = ["[a] punch", "[b] kick", "[c] magic"] restart = 1 myhp = 50 zomhp = 50 battle = 50  #game on screen if myhp <= 0:     print("you died")     print("game over")     quit()  #endless game function in range(0, reset):      #traveling loop     while battle > 5:         print(advlist)         trv = str(input("how advance?"))          if trv == advlist[0]:             sleep(8)             myhp = myhp + 10             battle = randint(0, 40)         if trv == advlist[1]:             sleep(4)             myhp = myhp + 5             battle = randint(0, 30)         if trv == advlist[2]:             sleep(2)             myhp = myhp + 2             battle = randint(0, 20)          if trv == advlist[3]:             sleep(1)             myhp = myhp + 1             battle = randint(0, 10)  #max health cap         if myhp >= 50:             myhp = 50         print("my hp: ", myhp)         print('')   #battle sequence     if battle <= 5:         print ("a zombie  approaches!!!")         sleep(1)         while battle <= 5:             print (atklist)             atk = str(input("how attack?"))             #randomizes hit chance             khit = randint(0, 2)             phit = randint(0, 1)             mhit = randint(0, 5)             zhit = randint(0, 4) #kick attack             if atk == "b":                 dmg = randint(1, 25)                 if khit != 1:                     print ("your attack missed...")                  if khit == 1:                     zomhp = zomhp - dmg                     print (("the attack hits %s damage") %(dmg)) #punch attack             if atk == "a":                 dmg = randint(1, 10)                 if phit == 0:                     print ("your attack missed...")                  if phit == 1:                     zomhp = zomhp - dmg                     print (("the attack hits %s damage") %(dmg)) #magic attack             if atk == "c":                 dmg = randint(1, 50)                 if mhit != 0:                     print ("your attack missed...")                  if mhit == 0:                     zomhp = zomhp - dmg                     print (("the attack hits %s damage") %(dmg) #zombie's hit             if zhit == 0:                 zdmg = randint(1, 10)                 myhp = myhp - zdmg                 print (("the zombie's attack hits %s damage")(zdmg))                 print ("my hp:", myhp) #zombie miss             if zhit != 0:             print ("my hp:", myhp) #zombie dies             if zomhp <= 0:                 print ("you defeated zombie!!!")                 battle = 50 #round end     print("zombie's hp:", zomhp)     print('') 

i getting error on line

file "<ipython-input-3-252d942b8c20>", line 82 if zhit == 0:             ^ syntaxerror: invalid syntax 

so, noticed "zhit" should not initialized 0 conflicts comparison operator. secondly, helpful if add comments code understand purpose of game. eof error on pep8, documentation pep8 maybe helpful, eof901 points e901 syntaxerror or indentationerror. in python, proper indentation important. hope helps http://pep8.readthedocs.io/en/release-1.7.x/intro.html

it idea copy code text editor such sublime, atom or visual studio , switch debugging mode step through code line line. tried code on jupyter notebook , did not find error albeit different one. https://repl.it/languages/python3 site has own debug environment. perhaps, identify source of error.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -