Want to know why that function doesn't work ?
students = {'dsd': 13}
student1 = {'dsdsd': 15}
print(students.update(student1))
After printing it just brings out None in console.
Because dict1.update(dict2) update the value of dict1 with the values of dict2 but do not returns anything (hence printing None in your case). In order to see the updated values, you need to do:
students.update(student1)
print(students)
As a reference, check dict.update() document which says:
Update the dictionary with the key/value pairs from other, overwriting existing keys. Return
None.
The update method merges the dicts in-place and returns 'None', which is what you're printing. You need to print students itself.
students = {'dsd': 13}
student1 = {'dsdsd': 15}
students.update(student1)
print(students)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With