We can use tolist() and list() to convert an array into a list in Python. The following is the syntax.
Method 1:
array.tolist()
Method 2:
list(array)
The following is to generate an array using Numpy.
import numpy as np
# create array
array_1 = np.array([5, 8, 4, 4])
print("Array_1:\n",array_1)
Array_1: [5 8 4 4]
Method 1: np.tolist()
# apply tolist()
list_1 = array_1.tolist()
print("list_1:\n",list_1)
list_1: [5, 8, 4, 4]
Method 2: list()
We can use Python built-in funtion list() to convert an array to a list.
# apply list()
list_1 = list(array_1)
print("list_1:\n",list_1)
list_1: [5, 8, 4, 4]