I have a problem why not change my “ln” variable in my program…?

In function i do with ln variable ln=ln+4 but only 0 remain

Hi Robi,

The issue with your code is that you actually have two variables `ln`

in play here. You define a global variable in line 11. But the function `Elenoriz`

has a parameter called `ln`

, too (line 13).

So, what happens is this: when you call `Elenoriz(i, j, ln)`

in line 37, Python *copies* your global variable `ln`

to a new local variable `ln`

for the function. As long as the function is running, you are always working with the local variable. This means that any changes to it will be lost as soon as the function returns/finishes.

I gues you might want to use `global ln`

instead, which tells Python to use the global variable even inside a function. `ln`

is then no longer a parameter and does not get copied into a new variable with the same name. Here is a very minimalistic version:

```
ln = 0
def Elenoriz(i, j):
global ln
...
ln = ln + 4
```

I hope this helps.

Cheers,

Tobias

P.S. Sorry for the late answer.