Methods in Dictionary in Python


Methods in Dictionary:

dict={1:"Hello",2:"Guys",3:"How",4:"are",5:"You"}
print(dict)


1.get() = returns the value to the specified key.

dict={1:"Hello",2:"Guys",3:"How",4:"are",5:"You"}
print(dict.get(1))


2.values()=returns all values of the dictionary.


dict={1:"Hello",2:"Guys",3:"How",4:"are",5:"You"}
print(dict.values())   


3.items()=returns the dictionary as tuples.


4.pop(): method removes the item with the specified key name.



Some other functions:




Post a Comment

0 Comments