Python Practice › NumPy Programs › Program 41
Array to list
Write a NumPy program to convert an array into a list.
Input
[[3, 0], [6, 4]]
Output
[[3, 0], [6, 4]]
Approach
.tolist()gives plain Python ints.
Solution
import numpy as npprint(np.array([[3, 0], [6, 4]]).tolist())Output
[[3, 0], [6, 4]]
Learn the concept
New to this topic? Read the lesson, then come back.