Simple nested dict
Input
get_nested({'a': {'b': 2}}, 'a.b', None)
Output
2
Path 'a.b' retrieves the nested value 2.
Full lesson preview
Safely access nested values in mappings and sequences, returning a default when any key/index is missing.
Problem statement
Task
Examples
Input
get_nested({'a': {'b': 2}}, 'a.b', None)
Output
2
Path 'a.b' retrieves the nested value 2.
Input format
Output format
Constraints
Samples
Input
get_nested({'x': 1}, 'y', 'missing')
Output
missing
Key 'y' is missing; function returns the provided default.