d = { "a" : 1, "b" : 2 }
# add pair
d["w"] = 27

# update pair
d["b"] = 10

# remove pair
d.pop("a")

###

words = [ "let's", "go", "tartans" ]
for word in words:
    print(word.upper())
    
###
  
d = { "a" : 4, "b" : 10, "c" : 20 }
total = 0
for k in d:
    total = total + d[k]
print(total)

###

words = [ "let's", "go", "tartans", "today" ]
result = { } # { letter : list of words that start with that letter }
for w in words:
    letter = w[0]
    if letter in result:
        #result[letter].append(word)
        result[letter] = result[letter] + [ w ]
    else: # letter is not in result
        result[letter] = [ w ]
print(result)

###

"""
write a program that takes a dictionary mapping strings to numbers and a limit (a number) and
returns True if all the keys are at most the limit in length, and False otherwise.

For example, hasShortKeys({ "abc" : 2, "de" : 5}, 3) would return True, but
hasShortKeys({ "abc" : 2, "defgh" : 2}, 4) would return False.
"""

def hasShortKeys(d, limit):
    for k in d:
        if len(k) > limit:
            return False
    return True