How do you return the value of a variable from a function?
For example, I want to use variable x. Say I start my program with "x=1".
Inside the function I have the statement x=x+1. However, when the function ends and I say "return x", if I have "print x" outside of that function, the value of x is still 1.
How do I initialize the variable outside of the function, allow the function access to this variable, and then return the new value once the function ends? Or in simpler terms, with the function stated above, how do I get x to be 2 outside the function?
Thanks!

Hey! We 've verified this expert answer for you, click below to unlock the details :)

I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!

Looking for something else?

Not the answer you are looking for? Search for more explanations.

## More answers

Looking for something else?

Not the answer you are looking for? Search for more explanations.