How to create global variables? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to create global variables?

14th Jun 2016, 6:32 AM
Ashray
Ashray - avatar
1 Answer
0
inside a function with the statement: global nameofyourvariable; def function (): global var; # this will asign a new value to var if already exists. var2 # (var2 is only for using in this function) ... otherwise with the same indent of your defs (and remember, before using it .... else: Error!!! variable is not defined :-) :-) :-) !).
18th Jun 2016, 2:47 PM
Tomas Ibarra