Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

How do I declare an array in Python?

I can't find any reference to arrays in the documentation.

1 Answer

0 votes
by (106k points)

There are many ways to declare Array in Python some of them are as follows:-

abc = []

Here, abc refers to an empty list.

It is an assignment, not a declaration.  We know Python is dynamically typed so there is no way that we can say that this variable will never refer to anything other than a list. In Python, the default built-in type is called a list, not an array.

Another way to create an array in Python is to use the following method :

from array import array

intarray = array('i')

Related questions

0 votes
1 answer
asked Oct 11, 2019 in Python by Sammy (47.6k points)
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...