Alter dictionary

Question

While recording the marks, Maria mistakenly added her Physics marks as 12. Correct it to be 20.

MariaMarks={

“Math”:18,

“Chemistry”:12,

“Physics”:12 }

in progress 0
YashikaKhurana 55 years 2 Answers 681 views Master 0

Answers ( 2 )

  1. Simply use the following line of code:
    MariaMarks[“Physics”]=20

  2. 1. Use Update() to either update existing record or add new record (key – value pair) in dictionary.
    MariaMarks.update({“Physics” : 20})

    2. MariaMarks[“Physics”]=20

Leave an answer

Browse
Browse