dictionaries counts 'chuck 'annie 'jan' print(counts get('jan' ) print(counts get('tim' ) we can use get to write our histogram loop more concisely because the get method automatically handles the case where key is not in dictionarywe can reduce four lines down to one and eliminate the if statement word 'brontosaurusd dict(for in wordd[cd get( , print(dthe use of the get method to simplify this counting loop ends up being very commonly used "idiomin python and we will use it many times in the rest of the book so you should take moment and compare the loop using the if statement and in operator with the loop using the get method they do exactly the same thingbut one is more succinct dictionaries and files one of the common uses of dictionary is to count the occurrence of words in file with some written text let' start with very simple file of words taken from the text of romeo and juliet for the first set of exampleswe will use shortened and simplified version of the text with no punctuation later we will work with the text of the scene with punctuation included but soft what light through yonder window breaks it is the east and juliet is the sun arise fair sun and kill the envious moon who is already sick and pale with grief we will write python program to read through the lines of the filebreak each line into list of wordsand then loop through each of the words in the line and count each word using dictionary you will see that we have two for loops the outer loop is reading the lines of the file and the inner loop is iterating through each of the words on that particular line this is an example of pattern called nested loops because one of the loops is the outer loop and the other loop is the inner loop because the inner loop executes all of its iterations each time the outer loop makes single iterationwe think of the inner loop as iterating "more quicklyand the outer loop as iterating more slowly the combination of the two nested loops ensures that we will count every word on every line of the input file