Open mhpranta12 opened 3 years ago
Actually you can convert numpy array to list by this also: list(array)
Here is an example:
import numpy as np
array = np.array([1, 2, 3]) //numpy array
print(type(array))
newlist = list (array) //converted to list
print (type(newlist))
In output you will see the type of newlist is list
So, the given answer was correct.
We can use the built-in Python function list() to convert a numpy array into a list. The following is the syntax:
ls = list(arr)
Here, arr is a numpy array.
I think this is the way to convert numpy array into a list : import numpy as np
1d array to list
arr = np.array([1, 2, 3]) print(f'NumPy Array:\n{arr}')
list1 = arr.tolist() print(f'List: {list1}')