

- 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 to print all the values of a dictionary in Python?
Dictionary object possesses values() method which does this job for us.
>>> D1 = {1:'a', 2:'b', 3:'c'} >>> D1.values() dict_values(['a', 'b', 'c']) >>> list(D1.values()) ['a', 'b', 'c']
You can also get corresponding value by iterating through lidt of keys returned by keys() method of dictionary
>>> L1 = list(D1.keys()) >>> for i in L1: print (i) a b c
- Related Questions & Answers
- How to print all the keys of a dictionary in Python?
- How to get a list of all the values from a Python dictionary?
- How to concatenate a Python dictionary to display all the values together?
- How to print a Python dictionary randomly?
- How to sum values of a Python dictionary?
- How to replace values of a Python dictionary?
- How to remove all the elements of a dictionary in Python?
- How to update a Python dictionary values?
- How to replace values in a Python dictionary?
- How to print the largest value from Python dictionary?
- How to get a list of all the keys from a Python dictionary?
- How to find the average of non-zero values in a Python dictionary?
- How to sort a dictionary in Python by values?
- Accessing Values of Dictionary in Python
- How to print Python dictionary into JSON format?
Advertisements