Update: I simplified the example and added expected result
I'm making a mistake, and can't figure it out.
When I run this, my expectation is that the initial_payload
will contain the first set of ['users'] from users_to_survey
, since i'm appending them before overwriting, and then when I overwrite the product_payload['users'], the reminder_payload
will contain the ['users'] from users_to_remind
.
But when i print initial_payload
at the end of this, it is identical to reminder_payload
. The ['users'] for both is the same
initial_payload = []
reminder_payload = []
product_payload = {
'product': 'colgate',
}
users_to_survey = ['kevin', 'dan']
if users_to_survey:
product_payload['users'] = users_to_survey
initial_payload.append(product_payload)
users_to_remind = ['bill', 'tom']
if users_to_remind:
product_payload['users'] = users_to_remind
reminder_payload.append(product_payload)
print(initial_payload)
print(reminder_payload)
I'm sure I'm missing something basic.