Guest User

Untitled

a guest
Jan 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. spisok=[{'a':'1','b':'2'},{'a':'3','b':'4'}]
  2.  
  3. for i in range(len(spisok)):
  4. if spisok[i]['a'] == stroka_poiska:
  5. print('True')
  6.  
  7. def chk_for_val(lst, key, val):
  8. for d in lst:
  9. if d.get(key) == val:
  10. return True
  11. return False
  12.  
  13. In [138]: chk_for_val(lst, 'a', '3')
  14. Out[138]: True
  15.  
  16. In [139]: chk_for_val(lst, 'X', '3')
  17. Out[139]: False
  18.  
  19. for i in range(len(spisok)):
  20. for key in spisok[i]:
  21. if spisok[i][key]=='4':
  22. print(spisok[i][key])
Add Comment
Please, Sign In to add comment