Dictionary Activity

In Class Group activity

Step 1

Create a shared repl.it as a clone from: https://repl.it/@JimSkon/NameDataLookupStart. Email the link to Professor Skon (skonjp@kenyon.edu)

Step 2

Modify readNameStats() to read in the file, breaking each line into a name string and a float percentage value.

Check your work by printing out your data.

Step 3

Further modify readNameStats() to put the names and percentages into a dictionary with the key being the name.

Test out that it works by trying to look something up.

Step 4

Modify lookupNameStats(nameDict,name) so that it looks up a name, and either returns None is it not there, or the percentage.

Test it all out!

Scroll to Top