GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • w3resource
  • Front End
  • HTML
  • CSS
  • JavaScript
  • HTML5
  • Schema.org
  • php.js
  • Twitter Bootstrap
  • Responsive Web Design tutorial
  • Zurb Foundation 3 tutorials
  • Pure CSS
  • HTML5 Canvas
  • JavaScript Course

This view

  • Original page
  • New address

GeezerVison is showing www.w3resource.com — Python: Get the length of an array - w3resource

Python: Get the length of an array

Last update on July 05 2025 07:14:24 (UTC/GMT +8 hours)


20. Get the Length of an Array

Write a Python program to get the length of an array.

Sample Solution:

Python Code:

from array import array
num_array = array('i', [10,20,30,40,50])
print("Length of the array is:")
print(len(num_array))

Sample Output:

Length of the array is:
5                                

For more Practice: Solve these Related Problems:

  • Write a Python program to print the number of elements in an array using the len() function.
  • Write a Python program to compare the lengths of two arrays and print which one is longer.
  • Write a Python program to implement a function that returns the length of an array without using len().
  • Write a Python program to create an array, remove an element, and then print the new length of the array.

Go to:

  • Python Array Exercises Home ↩
  • Python Exercises Home ↩

Previous: Write a Python program to get an array buffer information.
Next: Write a Python program to get the array size of types unsigned integer and float.

Python Code Editor:

Contribute your code and comments through Disqus.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.


  • Daily Coding Challenges & Projects
  • Weekly Trends and Language Statistics



You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.