Wednesday, January 22, 2025
HomeProgrammingPython Array length

Python Array length

In Python, you can find the length of an array (or a list, which is Python’s version of an array) using the len() function.

Here’s an example:

my_list = [1, 2, 3, 4, 5]
length = len(my_list)
print(length)

This will output:

5

This is because the list my_list contains 5 elements. The len() function works for other data types as well, such as strings, tuples, and dictionaries.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x