Python program to create one list from set and dictionary

Introduction :

In this quick python tutorial, we will learn how to create one list from one set or dictionary. A set can keep only unique elements and dictionary holds key-value pairs.

We can convert one dictionary or set to a list in python easily.

Let me show you how :

Python program :

Below is the program :

given_set = {1, 2, 3, 4, 5}
given_dict = {1: 'one', 2: 'two', 3: 'three', 4: 'four',5: 'five'}


Output :

This program will print the below output :

[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]

Here, givenset_ is a set and givendict_ is a dictionary. Using list constructor will convert it to a list.

Similar tutorials :

Where is the color and why codevscolor ?

Long story short, I love paintings and I paint on weekends. We(me and my wife) have one Youtube channel. Below is a video that I did recently. If you love this please do subscribe to support us 😊