list to set in python code example
Example 1: empty set python
a = {}
print(type(a))
a = set()
print(type(a))
Example 2: how to convert a set to a list in python
my_set = set([1,2,3,4])
my_list = list(my_set)
print my_list
>> [1, 2, 3, 4]
Example 3: convert list to set python
names = ['Barry', 'Alice', 'Bob', 'Bob']
unique_names = set(names)
Example 4: python set to list
pokemon_set = set(['Pikachu', 'Bulbasaur', 'Koffing' , 'Spearow', 'Vulpix'])
print(pokemon_set)
pokemon_list = list(pokemon_set)
print(pokemon_list)