How to Calculate the Size of an Array in Python | Python Tutorial

Array Length in Python Along With Examples

Sanjay Priyadarshi

--

Photo by Alex Knight on Unsplash

An array is a built-in data type into programming languages like C++ and Java.

In python, there is no built-in data type called an array. You can use third-party libraries and create arrays.

By the size of the array, I mean how many total numbers of elements are present in the array.

Here we will discuss how we can calculate the length of an array in python.

Python array length

In Python, an array is a collection of elements that are stored in a contiguous memory location.

The index starts from 0, not 1.

To find the length of the array in python, we’ll use the len() method.

The len() method will help us find the length of the array.

You need to keep one thing in mind while calculating the length of the array. Since the array index starts at 0 and not 1, the array’s length is one more than the highest index value of an array.

Syntax of len() method

len(name_of_your_array)

--

--

Sanjay Priyadarshi

Join a Community of People Who Love Javascript, Programming and Technology — codertoentrepreneurs.substack.com