Skip to content

Instantly share code, notes, and snippets.

@ayota
Created March 22, 2014 19:14
Show Gist options
  • Save ayota/9712667 to your computer and use it in GitHub Desktop.
Save ayota/9712667 to your computer and use it in GitHub Desktop.
python dict contacts
contacts = {'Shannon': {'phone': '202-555-1234', 'twitter': '@svt827', 'github': '@shannonturner' },
'Anupama': {'phone': '410-333-9876','twitter': '@iamtheanupama', 'github':''}}
# for contact in sorted(contacts.keys()):
# print "{0} : {1}".format(contact,contacts[contact]['phone'])
#
# for contact,info in sorted(contacts.items()):
# print "{0} : {1}".format(contact,info)
for contact,info in contacts.items():
print "Name: {0} \n Phone: {1} \n Twitter: {2} \n Github: {3}".format(contact,info['phone'],info['twitter'],info['github'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment