A dictionary in Python is a collection of Key and value pairs a key is an identifier for values, and the value can be of any type String, int, List, or a dictionary
Below is an example of an empty dictionary, Dictionaries are represented by flower Brackets {}, and Key and Value pairs are separated using a colon ": "
In the below example, we have created a dictionary and we are Outputting the elements of the Dictionary. Please note that the Key " 1 " has a value of ' a ' likewise the key " 2 " has a Value of " b " and so on.
we can use the function KEYS() to print out the list of all the keys.
we can use the function VALUES() to print out the list of all the Values.
In the below example, we are updating the value of key [5] to 'z'
We can use the pop() function to delete a Key Value Pair, for instance in the below example we are using the POP function to remove the key (1) and its value ('a')
We can use the del function to delete a Key Value Pair
0 Comments