Dictionaries are used to store data values in key : value pairs
Dictionaries are collection which is ordered, changeable and do not allow duplicates
Dictionary is written with curly brackets { }
Example
dictionary = {
"Fname": "neel",
"Sname": "patel",
"DOB": 18-12-1999
}
Print Dictionary
print() function are used for print Dictionary
Example
dictionary = {
"Fname": "neel",
"Sname": "patel",
"DOB": 18-12-1999
}
print(dictionary)
Output
{'Fname': 'neel', 'Sname': 'patel', 'DOB': -1993}
Python Dictionary items
dictionary items is ordered ,it means that items defined in ordered manner and that order will not change in any case
Dictionary items Changeable
Dictionary items is changeable, it means you can add, remove data in Dictionary after created Dictionary
Duplicate Not Allowed
Dictionary do not have two items with same key
Example
dictionary = {
"Fname": "neel",
"Sname": "patel",
"Year": 1999 ,
"Year": 2022
}
print(dictionary)
Output
{'Fname': 'neel', 'Sname': 'patel', 'Year': 2022}