I am setting a string to something in a function, then trying to print it in another to find that the string never changed. Am I doing something wrong?
Defining the variable at the top of my script
CHARNAME = "Unnamed"
Function setting the variable
def setName(name):
CHARNAME = name
print CHARNAME
Use of function
print CHARNAME
setName("1234")
print CHARNAME
Output
Unnamed
1234
Unnamed