How to initialize set from list elements in Python

1 Answer

0 votes
lst = [1, 2, 1, 1, 1, 5, 2, 7, 4, 9, 12, 4, 4, 12, 3]

st = {*lst}
         
print(st)
 
 
 
 
'''
run:
 
{1, 2, 3, 4, 5, 7, 9, 12}
 
'''

 



answered Nov 21, 2021 by avibootz

Related questions

...