python - "NameError: global name 'change' is not defined" + other errors -
I am quite new to Python, and I am currently using Python 3.3.3, if you are thinking My code is below, which I have written with a batch script, written from Python is a batch script code, I do not know what I am doing, but when I run it, I get an error in the name : The global name 'change' is not defined
. I used to check the syntax, and if you input my python code in the box to check it, then whatever you get will have two code errors, and there are some PEP-8 errors. I can not think what's wrong. I do not even know what most code errors are, and PAP-8 errors all line: __ column: __E 302 required 2 empty rows, 1 has been found
.
Global Subtotal Importing the Sub-Processing as the Global Count Number: (): While correct: Try: number = int (input ("input one number, please:")) sp .call ('cls', shell = tru) break except valueError: print ('Please enter a valid input ...') sp.call ('pause', shell = true) numberInput () change = number number verified () Def number Verify (): if change == 0: Number possible IsTrue () and: number = change def number is narrow (IsTrue): count = calculation + 1 integer = number # check To see if input # is valid if the number! = Integer: sp.call ('cls', shell = true) Print ("Please enter a valid number!") Loop () Other: Even if = number% 2 == 0: print (" (With '* X / 2') {} ". Format (number)) Answer = Number / 2 Other: Print (-1) with print (" 3 * x) "('3 * x)' * 3 Answer = Answerodo + 1 print (answer) if answer == 1: return status () and: number possible isTrue () def returnStats (): print ("returned as your original input {1}." Format (change) )) (Print) = 1 count = 0 sp.call ('pause', shell = true) number Verify) DIF check (): number = answer number correct IsTrue () number input ()
These rows should be
global change global count
change = 0 count = 0 < / Code>
When you want to refer to a global variable, the global
keyword is used, so using these values, a function should be such as:
def func (): global countdown count = cou Nt + 1
Comments
Post a Comment