How to convert set to list in Python

In this post, we will see how to convert set to list in Python.
It is very easy to convert set to list in Python.Please note that list can have duplicates but set cannot have duplicates.
You can simply use the list function to convert set to list in Python.
Let’s understand with the help of example.

s={1, 2, 3, 4, 5, 6} #Converting set to list using list function l=list(s) print(l) sCountry={'USA', 'France', 'Russia'} lCountry=list(sCountry) print(lCountry)

Output:

[1, 2, 3, 4, 5, 6]
[‘Russia’, ‘USA’, ‘France’]

As you can see, we have successfully converted set to list in Python.
That’s all about python set to list conversion.

Leave a Reply

Your email address will not be published. Required fields are marked *