Operator Name:
The update operator ( |= )
Overview:
The update operator ( |= ) updates the contents of the dictionary instance(known as the current object, self, this and in other names) with the contents from an another dictionary instance d2 or an iterable contaning itreables of name-value pairs.
Operands:
d1 - The current dictionary
d2 - The dictionary from which d1 needs to be updated
Return Value:
A dict instance containing the updated name-value pairs.
Example:
# Example Python program that updates a dictionary reconciled = {"S1":62.5, original.update(reconciled); |
Output:
{'S1': 62.5, 'S2': 110.5, 'S3': 125.1, 'S4': 220.8, 'S5': 37.5, 'S6': 293.1} |