convert to list python code example

Example 1: python string to array

>>> text = 'a b c'
>>> text = text.split(' ')
>>> text
[ 'a', 'b', 'c' ]

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: python set to list

pokemon_set = set(['Pikachu', 'Bulbasaur', 'Koffing' , 'Spearow', 'Vulpix'])
print(pokemon_set)
pokemon_list = list(pokemon_set)
print(pokemon_list)

Example 4: convert string to list python

word = "Hey Hello world"
print(list(word))
# output
# ["Hey", "Hello", "world"]

Tags:

Java Example