convert set to list Python


In this tutorial, we will see how to convert set to list in python.
You can use python list() function to convert set to list.It is simplest way to convert set to list.

Let’s understand with the help of example.

setOfFruits={'Apple','Orange','Banana'} print("set of Fruits:",setOfFruits) listOfFruits=list(setOfFruits) print("listOfFruits:",listOfFruits) setOfScales={1,2,3,4,5} print("set of scales:",setOfScales) listOfScales=list(setOfScales) print("list of scales:",listOfScales)


set of Fruits: {‘Apple’, ‘Banana’, ‘Orange’}
listOfFruits: [‘Apple’, ‘Banana’, ‘Orange’]
set of scales: {1, 2, 3, 4, 5}
list of scales: [1, 2, 3, 4, 5]

As you can see, list starts with open square bracket and ends with close square bracket.


Add Comment