How to convert a dictionary into a list in python

0 votes
Hi Guys,

I have a dictionary dataset in the Jupyter notebook. I want to convert it into a list.

Can anyone tell me how can I convert it?
Jun 25, 2020 in Python by akhtar
• 38,260 points

edited Jun 25, 2020 by akhtar 1,862 views

1 answer to this question.

0 votes

Hi@akhtar

You can convert a dictionary dataset into a list using items() function. I have attached an example for your reference.

  • ​Initialization of dictionary 
$ dict = { 'Jack': 10, 'Pop': 12, 'Bob': 31 }
  • Converting into a list of tuple   
$ list = list(dict.items())
  • Printing list of tuple
$ print(list) 
  • Output: 
[('Jack', 10), ('Pop', 12), ('Bob', 31)]
answered Jun 25, 2020 by MD
• 95,460 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
3,483 views
+1 vote
1 answer

How to convert records from csv to a list in Python?

If you are using Python 3.x then ...READ MORE

answered Jun 25, 2019 in Python by Arvind
• 3,050 points

edited Jun 26, 2019 by Kalgi 9,889 views
0 votes
1 answer

How to convert each list item into string in a column of data frame. ?

Hey, To split a string you can use ...READ MORE

answered Feb 5, 2020 in Python by Roshni
• 10,480 points
932 views
0 votes
0 answers

How to return dictionary keys as a list in Python?

Now, in Python >= 3.3, I get something ...READ MORE

Feb 18, 2022 in Python by Dev
• 6,000 points
446 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 4,468 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to convert a dataframe into list?

Hi@akhtar, You can convert your dataframe into list. ...READ MORE

answered Apr 25, 2020 in Python by MD
• 95,460 points
745 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP