ItSolutionStuff.com

How to Convert Dictionary Values into List in Python?

By Hardik Savani • October 30, 2023
Python

Hey,

This is a short guide on python dictionary convert values to list. This tutorial will give you a simple example of python change dictionary value to list. In this article, we will implement a python 3 convert dict values to list. step by step explain how to convert dictionary values into list in python.

There are several ways to convert python dictionary values to list. I will give you the following three examples to convert a dictionary to list in python.

1) Python Convert Dictionary Values to List Example

2) Python Convert Dictionary Keys to List Example

3) Python Convert Dictionary Items to List Example

So, without further ado, let's see simple examples:

You can use these examples with python3 (Python 3) version.

1) Python Convert Dictionary Values to List Example

main.py

myDictionary = {
  "id": 1,
  "name": "Hardik Savani",
  "email": "hardik@gmail.com"
}
  
# Python Convert Dictionary Values to List
newDictionary = list(myDictionary.values())
  
print(newDictionary)

Output:

[1, 'Hardik Savani', 'hardik@gmail.com']

2) Python Convert Dictionary Keys to List Example

main.py

myDictionary = {
  "id": 1,
  "name": "Hardik Savani",
  "email": "hardik@gmail.com"
}
  
# Python Convert Dictionary Keys to List
newDictionary = list(myDictionary.keys())
  
print(newDictionary)

Output:

['id', 'name', 'email']

3) Python Convert Dictionary Items to List Example

main.py

myDictionary = {
  "id": 1,
  "name": "Hardik Savani",
  "email": "hardik@gmail.com"
}
  
# Python Convert Dictionary Items to List
newDictionary = list(myDictionary.items())
  
print(newDictionary)

Output:

[('id', 1), ('name', 'Hardik Savani'), ('email', 'hardik@gmail.com')]

I hope it can help you...

Tags: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Get Length of Dictionary Python?

Read Now →

Python Dictionary Remove Duplicate Values Example

Read Now →

Python Dictionary Check if Value is Empty Example

Read Now →

How to Check if Python Dictionary is Empty or Not?

Read Now →

Check if Key Value Pair Exists in Dictionary Python Example

Read Now →

Python Dictionary Check if Value Exists Example

Read Now →

Python Dictionary Check if Key Exists Example

Read Now →

How to Update Value in Python Dictionary?

Read Now →

How to Change Value in Python Dictionary?

Read Now →

Python Dictionary Remove Element by Value Example

Read Now →

Python Dictionary Delete Item by Key Example

Read Now →

How to Remove Element from Python Dictionary?

Read Now →

How to Remove Item from Dictionary in Python?

Read Now →

How to Add Item in Dictionary Python?

Read Now →

Python Create JSON File from Dict Example

Read Now →