because they have local scope inside the function. you need to declare them as global, using
Note, if you don't assign to a name inside the function, it will use the global one, without need to declare it global
e.g.
Note that using globals is generally considered bad, pass arguments to functions and return from functions.
Also, using ALL_CAPS for function and names is not consistent with PEP8 recommendations.
global
keyword if you want to change the global name. Note, if you don't assign to a name inside the function, it will use the global one, without need to declare it global
e.g.
def SET_MOST_RECENT_BACKUP(): print("Step 3...") global MOST_RECENT_BACKUP MOST_RECENT_BACKUP = CURRENT_LIST_OF_BACKUPS[-1] print(MOST_RECENT_BACKUP)
CURRENT_LIST_OF_BACKUPS
is a list
and lists are mutable, that's why it "works" for it.Note that using globals is generally considered bad, pass arguments to functions and return from functions.
Also, using ALL_CAPS for function and names is not consistent with PEP8 recommendations.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs