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 answersi'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
Post a Comment