Python Practice › NumPy Programs › Program 40

List to array

EasyNumPy Programs · 40 of 100

Write a NumPy program to convert a list into an array.

Advertisement
Input
[[3, 0], [6, 4]]
Output
[[3 0]
 [6 4]]

Approach

  1. np.array().

Solution

Python
import numpy as npprint(np.array([[3, 0], [6, 4]]))
Output
[[3 0]
 [6 4]]
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More numpy programs

← All 100 NumPy Programs