
Python - Convert a set to a list
Python set can be converted to set using list
.
a = {1, 2, 3}
b = list(a)
print(b) # [1, 2, 3]
Check other examples. Empty set is converted to empty list.
a = list({1, 4, 3, 2})
b = list({'Apple', 1, -3})
c = list(set())
print(a) # [1, 2, 3, 4]
print(b) # [1, -3, 'Apple']
print(c) # []
Comments
Powered by Markdown