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

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -