Python: Convert Set to a List

Below are a few examples to convert a set to a list in Python Programming using the builtin list() function..

Example 1:

cities_set = {"New York", "London", "Paris", "Tokyo", "Mumbai"}

cities_list = list(cities_set)

print(cities_list)
Convert Set to List in Python Example


Example 2:

numbers_set = {3.21, 4, 5, 27, 2.1}

numbers_list = list(numbers_set)

print(numbers_list)
Example 2 - Set to List Python

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!