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