Basic nested lookup
Input
get_nested({'a': {'b': 2}}, ['a', 'b'])
Output
2
Follow 'a' to get {'b': 2}, then 'b' to get 2.
Full lesson preview
Traverse nested dictionaries by a sequence of keys and return a value or a default when any key is missing.
Problem statement
Task
Examples
Input
get_nested({'a': {'b': 2}}, ['a', 'b'])
Output
2
Follow 'a' to get {'b': 2}, then 'b' to get 2.
Input format
Output format
Constraints
Samples
Input
get_nested({'user': {'profile': {'name': 'Eve'}}}, ['user', 'profile', 'name'])
Output
Eve
Traverse user -> profile -> name to get 'Eve'.