Python 3 Dictionary
Each key is separated from its value by a colon (:), the items are separated by commas, and the whole thing is enclosed in curly braces. An empty dictionary without any items is written with just two curly braces, like this: {}.
Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples.
dict = {'Name': 'Keen', 'Age': 2009, 'Class': 'Summer Training'}
print ("dict['Name']: ", dict['Name'])
print ("dict['Age']: ", dict['Age'])
Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples.
dict = {'Name': 'Keen', 'Age': 2009, 'Class': 'Summer Training'}
print ("dict['Name']: ", dict['Name'])
print ("dict['Age']: ", dict['Age'])
Comments
Post a Comment