Home > Enterprise >  How to retrieve the value of 'Avengers'='Endgame'
How to retrieve the value of 'Avengers'='Endgame'

Time:10-03

ET={'movies':[{'DC':'Batman','Marvel':[{'Avengers':'Endgame','Spiderman':'NowayHome'}]}]}

CodePudding user response:

self explained

ET = {
    'movies': [{
        'DC': 'Batman',
        'Marvel': [{
            'Avengers': 'Endgame',
            'Spiderman': 'NowayHome'
        }]
    }]
}

'''
ET['movies'] => select key
ET['movies'][0] => select first list
ET['movies'][0]['Marvel'] => select key
.....
'''

Avengers = ET['movies'][0]['Marvel'][0]['Avengers']
print(Avengers) # Endgame

CodePudding user response:

If Entertainment is declared as

Entertainment = {'game':'football'}, {'other':[{'movies':'NowayHome'},{'songs':'latest'}]}

The answer will be

Entertainment[1]['other'][0]['movies']
  • Related