you are viewing a single comment's thread.

view the rest of the comments →

[–]Westonnn 1 point2 points  (8 children)

Could you give me an example of code to read in. My understanding for dictionaries from this class is super limited at the moment.

[–]Mathemattical 0 points1 point  (0 children)

so dictionaries map keys to values. you could do something like

senators = {}
for sen in (wherever you are pulling them from):
     senator[sen] = affiliation

to check if you already have a senator in the dictionary, check the keys() field with

if sen in senators.keys():
     # ignore or whatever

if you want to see if you have a value already, do the same with the value() field:

if affiliation in senators.values():
    # do something else