13. Problem to convert a set to a list

In this Python set program, we will convert a set to a list with the help of the below-given steps.

What is set?
Sets are used to store multiple items in a single variable.
The set is one of 4 built-in data types in Python used to store collections of data.
It is an unordered collection data type that is iterable, mutable and has no duplicate elements.

Convert a set to a list:

Steps to solve the program

1. Create a set using {}.
2. Add some elements in the set.
3. Convert a set to a list using list() function.
4. Print the output.

				
					Set = {1,2,3,4,5}
set_list = list(List)
print("Original set: ",Set)
print("set to list: ",set_list)
				
			

Output :

				
					Original set:  {1, 2, 3, 4, 5}
set to list:  [1, 2, 3, 4, 5]
				
			

Related Articles

convert a list to a set.

find the maximum element in a set.

Leave a Comment