Step-by-step Explanation:
-
playerScores = dict()
-
Creates an empty dictionary named playerScores.
-
-
Adding player scores:
-
Adds 2 entries to the dictionary:
- }
-
-
Deleting one entry:
-
Removes the key "MS Dhoni" from the dictionary.
-
Now it becomes:
- }
-
-
Printing values:
-
Loops through each key-value pair in the dictionary.
-
Since only "Akshar" is left, it prints:
Output:
-
Let me know if you'd like a version that prints both the name and score like:
0 Comments:
Post a Comment