I want to have a function that returns True when a given list of keys lead to an existing structure inside the dictionary. Each key corresponds to the depth level of the dictionary
The struggle that I have is the fact that both the length of the List (= amount of Keys) and the depth of the dictionary are dynamic
#Example Code:
keys1 = ["K1", "K3", "K4"]
keys2 = ["K2", "K6"]
keys3 = ["K1", "K6", "K4"]
dict = {
"K1": {
"K3": {
"K4": "a"
}
},
"K2": {
"K6": "b"
}
}
result = function(keys1, dict) #result should be True
result = function(keys2, dict) #result should be True
result = function(keys3, dict) #result should be False