Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Lodash Get Deep Access
00:00
5 left

Lodash Get Deep Access

MediumPython

Problem

Binance frontend configuration often contains deeply nested dictionaries and arrays, such as spot trading preferences or Binance Pay UI settings. Implement a Python function that retrieves a nested value using a lodash.get-style path without raising an exception when a path is missing.

Formal Specification

Implement get_value(obj, path, default_value).

  • obj is a nested Python dictionary or list.
  • path is either a dot and bracket string, such as "user.preferences[0].theme", or a list of path segments, such as ["user", "preferences", 0, "theme"].
  • Dot notation accesses dictionary keys.
  • Bracket notation supports nonnegative integer list indexes and quoted dictionary keys, such as ["display.name"].
  • Return the value at the path if every segment exists.
  • Return default_value only when the path cannot be resolved. An existing value of None must be returned as None.
  • Do not mutate obj.

Constraints

  • obj contains at most 10^4 nested containers or values.
  • The path contains at most 100 segments.
  • Valid paths use dot notation, integer brackets, or quoted bracket keys.
  • Dictionary keys and path segments are strings or nonnegative integers.
  • The input path is non-empty and syntactically valid.

Function Signature

def get_value(obj, path, default_value):
Interviewer

Your question is Lodash Get Deep Access. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.