python - function without args that uses elements precreated -



python - function without args that uses elements precreated -

this question has reply here:

function not changing global variable 3 answers

i'm making programme uses variable called "lev" must used in functions, doesn't need argument of function. mean, function makes things , changes "lev" value, need this:

>>> lev=8 >>> def t(): >>> print 1+1 >>> lev = lev+1 >>> t() >>> lev 9

that first idea, in practice, doing this, doesn't work.

i can't utilize "return" new "lev" variable, because there functions need homecoming true or false them , edits value of "lev" too, can't utilize "return" command. has idea? thanks

define global lev in function ...

>>> lev=8 >>> def t(): >>> global lev >>> print 1+1 >>> lev = lev+1 >>> t() >>> lev 9

python function python-2.7

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -