Created
October 19, 2017 21:38
-
-
Save marksagal/82e6686812118855ec11017d18e6ecbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A. Current Data - Poorly structured | |
contact_emails = { | |
'brian': '[email protected]', | |
'ted': '[email protected]', | |
'donald': '[email protected]' | |
} | |
# A. Loop | |
for name in contact_emails: | |
email = contact_emails[name] | |
print(name, email) | |
# B. Dicts wrapped in List | |
contact_emails = [ | |
{'name': 'brian', 'email': '[email protected]'}, | |
{'name': 'ted', 'email': '[email protected]'}, | |
{'name': 'donald', 'email': '[email protected]'} | |
] | |
# B. Loop | |
for info in contact_emails: | |
print(info['name'], info['email']) | |
# C. Tuples wrapped in List | |
contact_emails = [ | |
('biran', '[email protected]'), | |
('ted', '[email protected]'), | |
('donald', '[email protected]') | |
] | |
# C. Loop | |
for name, email in contact_emails: | |
print(name, email) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment