August 10, 2022 |25.0K Views

    Python Program to Convert Set into a List

      Share   Like
    Description
    Discussion

    In this video, we will write a program to Convert set into a list in Python Program

    Below is the list of approaches that we will cover in this section:
    1. Getting the elements using list()
    2. Getting the element using sorted() method

    Python list() function takes any iterable as a parameter and returns a list (iterable is an object that could be a sequence (string, tuples) or collection). 

    The another method we are going to cover is sorted() method, this will convert the set into list in a defined order. The only drawback of this method is that the elements of the set need to be sortable, and it return only unique number.

    Python | Convert set into a list
    https://www.geeksforgeeks.org/python-convert-set-into-a-list/