E
E
estry2021-10-05 20:04:46
Python
estry, 2021-10-05 20:04:46

How to change the value of a variable from a function?

Hello. Is there a way to change the value of a variable from within a function?

Here is a sample code. We need to replace the value of the variable n from the flop() function

n=0

@decaratorblablabla()
async def floop()
    #тут какой то код вычисления
    n = результат_вычисления

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nikitin, 2021-10-05
@pydroider3

Through global
n=0
@decaratorblablabla()
async def flop()
global n #here
is some calculation code
n = calculation_result

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question