Q:

Create a Python project to get a property from a nested object using a dot path

0

Create a Python project to get a property from a nested object using a dot path.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#Source:  https://bit.ly/2OEBGUj
from property import get
data = {
    'code': 'S0001',
    'nested': {'x': 'y', 'int': 0, 'null': None},
    'nums': [[12, 14, 16, 18, 20]],
    'names': ['Hank Navas', 'Melinda Swatzell', 'Lucio Tardy', 'Hershel Luebke']
     }

print(get(data, 'code'))
print(get(data, 'nested.x'))
print(get(data, 'nested.null'))
print(get(data, 'nums.0.2'))
print(get(data, 'nums.0.-1'))
print(get(data, 'names.0'))
print(get(data, 'names.-1'))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now