I am trying to use a Gotcha statement to hold a list of variables for comparison. But at the end of my procedure I want to reset this list so that it is blank and the process can be restarted. Here is a simple example of what I want, and what I am actually getting:
def append_to(element, reset, to = []):
if reset == 'reset':
to = []
return
to.append(element)
return to
my_list = append_to(12, 'Not reset')
print my_list
my_other_list = append_to(42, 'Not reset')
print my_other_list
append_to(1, 'reset')
my_list = append_to(13, 'Not reset')
print my_list
my_other_list = append_to(43, 'Not reset')
print my_other_list
This is the output:
[12]
[12, 42]
[12, 42, 13]
[12, 42, 13, 43]
Output desired:
[12]
[12, 42]
[13]
[13,43]
How can I go about resetting this list? Thanks