Skip to content

Instantly share code, notes, and snippets.

@joetechem
Created January 27, 2017 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joetechem/b145ad5423686b0cf2e4645e1f64b18f to your computer and use it in GitHub Desktop.
Save joetechem/b145ad5423686b0cf2e4645e1f64b18f to your computer and use it in GitHub Desktop.
nesting dictionaries in a list
from dictionary import * # importing another program so we can use its code in this new program
# START WITH AN EMPTY LIST
classmates = []
# USING THE APPEND FUNCTION TO ADD DICTIONARIES TO THE EMPTY LIST
classmates.append(john)
classmates.append(jane)
classmates.append(sue, james, bart) # adding multiple dictionaries at one time
# now, test it:
print(classmates) # prints all the new data
# or
print(classmates[2]) # prints the third item in the list. Remember, lists are 0-based, so Python starts numbering at 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment