Python Practice › NumPy Programs › Program 41

Array to list

EasyNumPy Programs · 41 of 100

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

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

Approach

  1. .tolist() gives plain Python ints.

Solution

Python
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.

More numpy programs

← All 100 NumPy Programs

Leave a Comment