Skip to main content

list()

list(arr)

Casts an array into a list.

Input:
arr : array
Array that you want to cast into a list.
Returns:
new_list - A new list that contains every element from the array, in list form.
Return Type:
List

pets_arr = np.array(["dog", "cat", "hamster", "cat", "cat", "dog", "dog", "hamster", "hamster"])
pet_arr

array(["dog", "cat", "hamster", "cat", "cat", "dog", "dog", "hamster", "hamster"])

pet_list = list(pet_arr)
pet_list

["dog", "cat", "hamster", "cat", "cat", "dog", "dog", "hamster", "hamster"]