
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Access Python Dictionary in Simple Way
There are two ways available to access value associated with a key in a dictionary collection object. The dictionary class method get() takes key as argument and returns value.
>>> d1 = {'name': 'Ravi', 'age': 23, 'marks': 56} >>> d1.get('age') 23
Another way is to use key inside square brackets in front of dictionary object
>>> d1 = {'name': 'Ravi', 'age': 23, 'marks': 56} >>> d1['age'] 23
Advertisements