chevron_left
933 points
8 4 2

Problem:

I am a beginner in programming language and I choose python for this. So I was doing my programming practice. I was looking for a way to convert set to list data structure python. It should work perfectly I don't know how to do as I have never studied the set before as I come from the c language background.so waiting for some to help me on this.

Thank you

Solution:

I have got the issue you are facing you just want to convert set to list in python, basically, I come from c language background so this is getting me mad but at the same time I am enjoying it, so this is possible with the python in build function list and this is a really very easy step to work with let me show you how it works below is the step for this.

suppose you have a set that contains:

Input : {1, 2, 3, 4}

This input is converted to the list with the help of the list ( ) function as below.

Output : [1, 2, 3, 4]

Simple program:

# Python3 program to convert a 
# set into a list 
my_set = {'Kodlogs', 'for', 'students'} 

s = list(my_set) 
print(s) 

O Output:

[ 'Kodlogs','for','studetn']

I hope is going to help you, if you still face any issue let us know Happy coding!!

More Posts

Convert string to list python Naymul01 - Oct 16
Convert list to string python Naymul01 - Oct 4
How to convert list into dictionary in Python Prasandeep Gautam - Oct 17, 2020
How to set a timer in python ? Naymul01 - Oct 19
How to make an empty set in python ? Naymul01 - Oct 17
Can't convert 'list' object to str implicitly Naymul01 - 4 days
How to convert tuple to list ? Naymul01 - Oct 19
Which method can be used to convert a tuple to a list? Naymul01 - Oct 19
What method can be used to convert a list to a tuple? Naymul01 - Oct 18
Convert numpy array to list Naymul01 - Oct 14