COMP 1005 Lecture Notes - Lecture 11: Word Search
Document Summary
A dictionary is a set of key-value entries. The key can represent an item such as a string. The value can represent the occurrence or the frequency of the key. Key-values are separated by colons : and all key-values are embraced by curly brackets { }. Explained simply, a dictionary is a collection of items that are unordered, changeable, and indexed. In this example we created a dictionary called thisdict and included details about a car. The brand of the car is ford, and we separated both of them with a colon : then we wrote the model and year. Make sure to use commas as shown in the code if you want to break each component up. Counting the item frequencies of a list means to count the number of times each element appears in the list. In this example we converted a string, snowstorm into a dictionary, splitting it up by letters and counting the item frequencies.