The value of x is not changing due to the scope reference. Within your function you are referencing a local variable, x, not the global variable x. You would want to set the value of x to the value being returned by your function.
if x == 0:
x = function(x)
Alternatively, you can use global
inside your function to reference the global variable, however, it would be best to not mix the global and local scopes.
Additionally, it is better to not use the same variable declarations for this reason.
It can become confusing when you share variable names and it is very easy to override values when not intended.
Think of scope as a conversation you're having: You have two friends named John, but they are not the same person. If you wish to only talk to one John and not the other, then you declare that by selecting the desired John, in this case the variable x.
When debugging, it is useful to know what you are getting so in the future you should output the actual value of the variable to determine if that value is what you expected it to be.
if x == 0:
function(x)
print(x) # Prints 0
Added to the modified function call:
if x == 0:
x = function(x)
print(x) # Prints 100001