A really simple question, and I'm sure I knew it but must have forgotten
When running this code:
x = 0
def run_5():
print "5 minutes later"
x += 5
print x, "minutes since start"
run_5()
print x
I get x isn't defined. How can I have x used in the function and effected outside of it?
Just return a value ?
x = 0
def run_5():
print "5 minutes later"
x += 5
return x
x=run_5()
print x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With