tutorialsPythonBasic.verybasic.functions.function_local_variables module

Remember that the variables passed to a function are local, even if they are named the same as one of the “outside” variables.

tutorialsPythonBasic.verybasic.functions.function_local_variables.add_one_and_print(x)[source]

Add one to the number and print it, showcasing local variables.

Let’s create a variable named x and set it to a number

>>> x = 5

Let’s call the function

>>> add_one_and_print(x)
6

Obviously the ‘x’ inside the function changed to 6, what about the “outside” one?

>>> x
5

It’s still 5, since the ‘x’ inside the function was a local variable.