Home >Backend Development >Python Tutorial >How to convert list to set in python
The set() function creates an unordered set of non-repeating elements, which can perform relationship testing, delete duplicate data, and calculate intersection, difference, union, etc.
set Syntax: (Recommended learning: Python video tutorial)
class set([iterable])
Parameter description :
iterable -- iterable object object;
Return value:
Returns a new collection object.
Convert the list to a set:
list1=[1,3,4,3,2,1] list1=set(list1) print(list1)
The result is as follows:
(1,2,3,4)
For more Python-related technical articles, please visit Python Tutorial column for learning!
The above is the detailed content of How to convert list to set in python. For more information, please follow other related articles on the PHP Chinese website!