I am trying to append many variables that are zeep
objects to a list. However, when I print out the list at the end, each variable in the list has the same data.
I have tried isolating when the variable gets overwritten, and it's happening when I put a new value into the variable with the same name, but I do this after I append the variable to the list. So I am confused as to why this is happening. I've tried to use different variable names, but it results in the same problem.
def create_json_list(json_template):
newVar = json_template
newVar['name'] = unique_name
list.append(newVar)
newVar = json_template
newVar['name'] = unique_name2
list.append(newVar)
print(list[0]['name'])
print(list[1]['name'])
# At this point, the same name gets printed twice