Kimossab

Testing Dictionaries Inside Lists

Jul 8th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. contact_list = [{'Name':'Luis', 'Number':351916675561},{'Name':'Kimossab','Number':-1}];
  2.  
  3. str = input('Insert a name to look for the number: ');
  4. bool = 0
  5. for i in contact_list:
  6.     if i['Name'] != str:
  7.         continue
  8.     else:
  9.         bool = 1
  10.         print(i['Number'])
  11.  
  12. if bool == 0:
  13.     print('Name not found.')
Advertisement
Add Comment
Please, Sign In to add comment