Lisette's Dictionary knowledge

by Lisette Dunham

08 Jun 2017

Prior to reading the textbook -Dictionaries are lists that can contain different types of data (it’s like a list of lists) -Dictionary have keys that must be unique (otherwise they will write over each other) -keys can be any type of data -python does some mathematical magic that moves the keys around in the dictionary and thus will print in a different order every time -you can use loops to populate or add to a dictionary -you can use a dictionary to store information that would be useful to return to a game player later -you can index dictionaries like lists -an empty dictionary is defined by {}

Additional things I learned while reading the textbook -keys map to values, they are called a key-value pair or an item -you can use [] to call an item from the dictionary -len(dictionary) will return number of key-value pairs -looping through a dictionary makes counting easy -you can use the translate function to remove punctionation when counting the number of words in text

Lisette is a Research Data Statistical Analyst at UNC's Lineberger Comprehensive Cancer Center Find Lisette Dunham on Twitter, Github, and on the web.