Created
January 27, 2017 20:58
-
-
Save joetechem/b145ad5423686b0cf2e4645e1f64b18f to your computer and use it in GitHub Desktop.
nesting dictionaries in a list
This file contains 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
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