Advertisement
furas

Python - find element

May 31st, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. s = {'First Thing': {'ItemID':'0010152', 'Name': 'iPhone Black Cover', 'Category': 'Accessories','Price':610,'Count':56}, 'Second Thing': {'ItemID':'0011181' , 'Name': 'Burger', 'Category': 'Food & Drink','Price':349,'Count':70}, 'Third Thing': {'ItemID':'3520364' , 'Name': 'Engineering Geology 12th Edition', 'Category': 'Books','Price':499,'Count':45}, 'Fourth Thing': {'ItemID':'1256219' , 'Name': 'Call of Duty:Infinite Warfare', 'Category': 'Games','Price':999,'Count':89}}
  2.  
  3. my_id = '3520364'
  4.  
  5. for key, val in s.items():
  6.     if val['ItemID'] == my_id:
  7.         print('key:', key)
  8.         print('val:', val)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement