Share
Alter dictionary
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
While recording the marks, Maria mistakenly added her Physics marks as 12. Correct it to be 20.
MariaMarks={
“Math”:18,
“Chemistry”:12,
“Physics”:12 }
Answers ( 2 )
Simply use the following line of code:
MariaMarks[“Physics”]=20
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