Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How do I access an a dictionary element within in a list within a dictionary

$
0
0

I have the following data structurer returned from an API and I need to manipulate the "expiresAt" element. I can't understand why I am getting the list index is out of range

User = {"name": "Russell Sage","password:": "Test123","emailPasswordToUser": False,"authorizations" : [        {"ssidNumber": 1,"expiresAt": "2018-03-13T00:00:00.090210Z"        }    ]}expiryDate  = User["authorizations"][1]["expiresAt"]print(ExpiryDate)

Traceback (most recent call last):\Meraki\venv\Dictionary.py", line 17, in

expiryDate  = User["authorizations"][1]["expiresAt"]

IndexError: list index out of range

I have tried searching numerous python coding websites and searched the forums for something similar but came up blank."expiresAt" at is clearly index 1 in the list associated with dictionary key "authorizations"

If I simplify expiryDate = MerakiUser["authorizations"]i get[{'ssidNumber': 1, 'expiresAt': '2018-03-13T00:00:00.090210Z'}] which I believe is then a string rather than a list of dictionary items


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>