Guest User

Untitled

a guest
Oct 20th, 2017
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. # A. Current Data - Poorly structured
  2. contact_emails = {
  3. 'brian': 'brian@google.com',
  4. 'ted': 'ted@google.com',
  5. 'donald': 'donald@google.com'
  6. }
  7.  
  8. # A. Loop
  9. for name in contact_emails:
  10. email = contact_emails[name]
  11. print(name, email)
  12.  
  13.  
  14. # B. Dicts wrapped in List
  15. contact_emails = [
  16. {'name': 'brian', 'email': 'brian@google.com'},
  17. {'name': 'ted', 'email': 'ted@google.com'},
  18. {'name': 'donald', 'email': 'donald@google.com'}
  19. ]
  20.  
  21. # B. Loop
  22. for info in contact_emails:
  23. print(info['name'], info['email'])
  24.  
  25.  
  26. # C. Tuples wrapped in List
  27. contact_emails = [
  28. ('biran', 'brian@google.com'),
  29. ('ted', 'ted@google.com'),
  30. ('donald', 'donald@google.com')
  31. ]
  32.  
  33. # C. Loop
  34. for name, email in contact_emails:
  35. print(name, email)
Add Comment
Please, Sign In to add comment