How can I get list of values from dict

0 votes
How can I get a list of the values in a dict in Python?

In Java, getting the values of a Map as a List is as easy as doing list = map.values();. I'm wondering if there is a similarly simple way in Python to get a list of values from a dict.
Feb 14 in Python by Dev
• 6,000 points
20 views

1 answer to this question.

0 votes

Here is an example to get the values from dictionary in Python 

dict_example = {'Name': "Sam", 'Age': 34}
list(dict_example.values())

Output

['Sam', 34]
list(dict_example.keys())

Output

['Name', 'Age']

Thus this is a simple way to get dictionary values and key from dictionary in Python.

answered Feb 14 by Nandini
• 5,480 points

Related Questions In Python

0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
2,553 views
0 votes
1 answer

How can I get a list of locally installed Python modules?

Solution My 50 cents for getting a pip freeze-like ...READ MORE

answered May 24, 2018 in Python by charlie_brown
• 7,710 points
612 views
0 votes
2 answers

How can I get the count of a list in Python?

n=[1,2,3,4,5,6,7,8,9] print(len(n)) =9 READ MORE

answered Dec 10, 2020 in Python by anonymous
609 views
0 votes
1 answer

How can I get dict from sqlite query?

Hii, Even using the sqlite3.Row class-- you still ...READ MORE

answered Apr 30, 2020 in Python by Niroj
• 82,680 points
2,877 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,743 views
0 votes
1 answer
0 votes
1 answer

How can I count the occurrences of a list item?

For Counting the occurrences there are many ...READ MORE

answered Feb 7 in Python by Nandini
• 5,480 points
20 views
0 votes
1 answer

How can I add new keys to a dictionary in Python?

Yes, it is possible to add new ...READ MORE

answered Feb 9 in Python by Nandini
• 5,480 points
24 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP