James Moore MOAR Dictionary Exercises

by James Moore

06 Apr 2016

Exercise 1:

Exercise 2-5:

These exercises were much easier having read the regex chapter. At first, I was hesitant to implement regex in my code because I wasn’t confident enought that I could come up with viable regex expressions in an effiicient enough manner. However, I found a nifty website (https://regex101.com/) that allowed me to test differet regexes outside the scope of the rest of my code. Therefore I could just copy and paste a line from mbox-short.txt into regex101 to test out regexes to see if they worked.

This exercise also hammered home how to access the key of a dictionary as opposed to its value. For whatever reason some of the stumbling blocks I encountered involved accessing the value when I meant to access the key and vice versa. With this practice using for loops to navigage and build dictionaries, it really helped me understand dictionaries a little bit more.

But despite this added knowledge I was unable to figure out exercise 5. Really it came down to the fact that I couldn’t build a regex to capture just the domain name. I’ll be interested to see how you figured this out.

Hi my name is James. I'm a 1st year Masters student. Find James Moore on Twitter, Github, and on the web.