Given a map scores from names to scores and a name, return the score of name, or 0 when name isn't a key of scores.
Some names you look up aren't in the dictionary at all. They have no score, so the answer for them is 0.
Example 1:
Input: scores = {"Ana": 90, "Ben": 75, "Cara": 88}, name = "Ben"
Output: 75
Explanation: "Ben" is a key of scores, and its value is 75.
Example 2:
Input: scores = {"Ana": 90, "Ben": 75, "Cara": 88}, name = "Dan"
Output: 0
Explanation: "Dan" isn't a key of scores, so the answer is 0.
Example 3:
Input: scores = {}, name = "Ana"
Output: 0
Explanation: An empty dictionary has no keys at all.
Constraints:
scorescan be empty.- Names are single words made of English letters, and the names in
scoresare all different. namematches a key only when it is spelled exactly the same, upper and lower case included:"ana"is not"Ana".- Every score is between 0 and 100.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
