Python 20 Programming Tutorial - Dictionaries


classmates = {'Tony': 'cool but smells', 'Emma': 'sits behind me', 'Lucy': 'asks too many questions'}
weights = {'Tony': 150, 'Emma': 87, 'Lucy': 385}


print(classmates)
print(classmates['Emma'])


for k, v in weights.items():
    print(k + " weighs " + str(v))

你可能感兴趣的:(Python 20 Programming Tutorial - Dictionaries)