
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does Python dictionary keys() Method work?
The keys() method of Python dictionary class returns a view object consisting of keys used in the dictionary.
>>> d1 = {'name': 'Ravi', 'age': 21, 'marks': 60, 'course': 'Computer Engg'} >>>d1.keys() dict_keys(['name', 'age', 'marks', 'course'])
It can be stored as a list object. If new key-value pair is added, the view object is automatically updated.
>>> l1=d1.keys() >>> l1 dict_keys(['name', 'age', 'marks', 'course']) >>>d1.update({"college":"IITB"}) >>> l1 dict_keys(['name', 'age', 'marks', 'course', 'college'])
- Related Questions & Answers
- How does constructor method __init__ work in Python?
- How does jQuery replaceWith() method work?
- How does the destructor method __del__() work in Python?
- Properties of Dictionary Keys in Python
- Python Extract specific keys from dictionary?
- Python - Cumulative Mean of Dictionary keys
- How to create Python dictionary with duplicate keys?
- How does jQuery.slice() method work in jQuery?
- How does jQuery.filter() method work in jQuery?
- How does jQuery.find() method work in jQuery?
- How does jQuery.eq() method work in jQuery?
- How does jQuery.map() method work in jQuery?
- How does jQuery.clone() method work in jQuery?
- How does jQuery.nextAll() method work in jQuery?
- How does the pandas series.ffill() method work?
Advertisements