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)

Convert Set to List in Python Example

Example 2:

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

numbers_list = list(numbers_set)

Example 2 - Set to List Python

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

Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

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