What is the difference between updation and addition of elements to a dictionary?

 

Answer:

The difference between updation and addition of elements to a dictionary is that updation means changing the value of an existing key , while addition means adding a new key-value pair to the dictionary.

To update a value, you can use the assignment operator = or the update() method.The assignment operator takes the name of the dictionary followed by the key in square brackets as the left operand and the new value as the right operand. 

To add a new key-value pair, you can also use the assignment operator = or the update() method. The assignment operator takes the name of the dictionary followed by the new key in square brackets as the left operand and the new value as the right operand.

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.