In [ ]:
d = {
    "ATL" : {"wins": 5, "losses": 3, "ties": 0},
    "CHC" : {"wins": 7, "losses": 2, "ties": 1}
}
In [ ]:
d["ATL"]["wins"]
Out[ ]:
5
In [ ]:
d["ATL"]["wins"] = 6
In [ ]:
d
Out[ ]:
{'ATL': {'wins': 6, 'losses': 3, 'ties': 0},
 'CHC': {'wins': 7, 'losses': 2, 'ties': 1}}
In [ ]:
d["ATL"]["wins"] = d["ATL"]["wins"] + 1
In [ ]:
d
Out[ ]:
{'ATL': {'wins': 7, 'losses': 3, 'ties': 0},
 'CHC': {'wins': 7, 'losses': 2, 'ties': 1}}
In [ ]:
x = 5
x = x + 1
print(x)
6
In [ ]:
p1_str = "4:3,2:1,-3:0"  # string representation of polynomial
p1_list = [(4,3),(2,3),-3,0]
p1_dict = { 3: 4, 2: 3, -3: 0 }
In [ ]:
def convert_str_list(s):
    pass

def convert_list_str(xs):
    pass

# for example s = "4:3,2:1,-3:0,10:3"
def convert_str_dict(s):
    d = {}
    xs = s.split(",")
    for x in xs:
        ys = x.split(":")
        if int(ys[1]) not in d:
            d[int(ys[1])] = int(ys[0])
        else:
            d[int(ys[1])] = d[int(ys[1])] + int(ys[0])
    return d


# 6 of these functions
In [ ]:
convert_str_dict("4:3,2:1,-3:0,10:3,20:3,40:3")
Out[ ]:
{3: 74, 1: 2, 0: -3}