So I have a list like the following
[{'id': '290910533794791424', 'invite': 'KEY', 'orderid': 'YMHBK8', 'order': 'specified value'}]
How would I obtain a certain value such as the orderid
?
So I have a list like the following
[{'id': '290910533794791424', 'invite': 'KEY', 'orderid': 'YMHBK8', 'order': 'specified value'}]
How would I obtain a certain value such as the orderid
?
You have a list containing a single dictionary.
Therefore, you can retrieve the value for a given key by either extracting the first element explicitly or iterating the list once:
lst = [{'id': '290910533794791424', 'invite': 'KEY',
'orderid': 'YMHBK8', 'order': 'specified value'}]
res = next(iter(lst))['orderid'] # 'YMHBK8'
res = lst[0]['orderid'] # 'YMHBK8'