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

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap