Dynamic Path Accessor

**Hi! Just a heads-up ~ FastPrep currently doesn't support dictionaries as an input type, so submitting code with that will throw errors. But no worries! The problem statement is pretty clear about what’s expected **

Implement a function called get_dict_value that takes two arguments: a dictionary called dict and a string called path. The path string represents the nested keys of the dictionary, separated by dots. The function should return the value at the specified path or None (the Python null value, not a string) if the path does not exist.

Function Description

Complete the function get_dict_value in the editor below.

get_dict_value has the following parameters:

  • obj: a Python dictionary
  • string path: the path to the desired value if it exists

Returns

The value at the specified path, or None (the Python null value, not a string) if the path does not exist

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: