Why does this code pull the same info inside and outside of function?

I agree. I think you have posted 4 blocks of code, and if you put three backticks at the beginning of each, and three backticks at the end of each, you’ll be amazed how much more readable it all gets.

Yes. It creates a new variable, locally inside sample_function, assigns 37 to it and returns that value. So the value of sample_function(), every time you call it, is 37, which never affects, or is altered by, the value of number at the global scope.

1 Like