Back to Lookup By Value

Dictionaries · Lookup By Value · Practice Question

Extract the last key by value

Sign in to track your progress

Question

Given the dictionary:

dict:`a`b`c`d`e!9 2 9 2 1

Extract the last key whose value is 9.

Solution

last where dict = 9

Result:

`c

Explanation

where dict = 9 returns `a`c — the keys whose value is 9 — and last picks `c. Find (?) isn't suitable here since it only ever returns the first matching key.