What's the difference between a key and a value?


For the example given, the keys are animal names and the values are numbers, but in a different example, they suggest that a dictionary could be used to pair email addresses and usernames. In that scenario, which would be the key and which would be the value? Is it possible to have an int key and a string value? Does the key always come first?


In the email vs username example, either could be the key. I would suggest the email to be the value, but it doesn't really matter. It is possible for any data type to be the key or value. (I am pretty sure) I am not sure what you mean by does the key come first, but when writing a dictionary the key is the one on the left.

Ex: things = ["Eggs" : 12, "Hungry: : True, "Animals" : ["dogs","cats"]]

A list can be in a dictionary too!