This code doesn't initializes the variables that I expect to be initialized.
a,b,c = [None]*3
def __init_abc():
a="a"
b="b"
c="c"
def print_abc():
__init_abc()
print(a,b,c)
print_abc()
Output is:
None None None
This code doesn't initializes the variables that I expect to be initialized.
a,b,c = [None]*3
def __init_abc():
a="a"
b="b"
c="c"
def print_abc():
__init_abc()
print(a,b,c)
print_abc()
Output is:
None None None
Within the __init_abc
function you need to specify the global variables a
, b
, c
otherwise the variables are presumed to be local to the function.
a,b,c = [None]*3
def __init_abc():
global a,b,c
a="a"
b="b"
c="c"
def print_abc():
__init_abc()
print(a,b,c)
print_abc()
Output:
a b c