Dictionary Data Type

suggest change

A dictionary consists of key-value pairs. It is enclosed by curly braces {} and values can be assigned and accessed using square brackets [].

dic={'name':'red','age':10}
print(dic)    #will output all the key-value pairs. {'name': 'red', 'age': 10}
print(dic['name'])    #will output only the value with the 'name' key. red
print(dic.values())    #dict_values(['red', 10]), not a list
print(dic.keys())    #dict_keys(['name', 'age']), not a list

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents