fork download
  1. dict1 = {
  2. "items": {
  3. "443b52fc-4eba-4165-9b01-92281e877896": {
  4. "templateId": "ConditionalAction:generic_instance"
  5. },
  6. "6c882c1e-bccd-4c21-83ad-aef87f6c6d12": {
  7. "templateId": "AthenaRewardGraph:s19_winterfest"
  8. },
  9. }
  10. }
  11.  
  12.  
  13. # If there are multiple elements with templateId = :s19_winterfest
  14. list1 = [k for k, v in dict1['items'].items() if v['templateId'] == 'AthenaRewardGraph:s19_winterfest']
  15. print(list1)
  16.  
  17. # Find one first desired element
  18. result = None
  19. for k, v in dict1['items'].items():
  20. if v['templateId'] == 'AthenaRewardGraph:s19_winterfest':
  21. result = k
  22. break
  23. print(result)
  24.  
Success #stdin #stdout 0.03s 9088KB
stdin
Standard input is empty
stdout
['6c882c1e-bccd-4c21-83ad-aef87f6c6d12']
6c882c1e-bccd-4c21-83ad-aef87f6c6d12