Bejan Muhidinov Bejan Muhidinov - 6 days ago 5
Python Question

Dictionary update method. Python 3.4

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.

Answer

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)
Comments