Python Dictionary Methods

Python Dictionary Methods:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

(1) get() Returns the value corresponding to the key passed as the argument. If the key is not present in the dictionary it will return none.

python get function in dictionary

(2) keys() Returns a list of keys in the dictionary.

python keys function in dictionary

(3) values() Returns a list of values in the dictionary.

values function of dictionary in python

(4) items() Returns a list of tuples (key-value) pairs.

python items function in dictionary

(5) del Deletes the item with the given key.

python del keyword in dictionary

(6) pop() Removes an element from the dictionary whose key is given as its argument.

python pop function in dictionary

(7) dict() Creates a dictionary from a sequence of key-value pairs.

dict function in python

(8) update() Updates the dictionary with the specified key and value.

python update function in dictionary

(9) clear() Deletes or clears all the items in the dictionary.

python clear function in dictionary

Tutorial Python
Tutorial MySQL
Object-Oriented Programming (OOP)
Procedure-Oriented Programming

Email (Electronic Mail)
Database Models or Data Models

Information Security in E-Commerce

Python (programming language)– Wikipedia

Comments (No)

Leave a Reply