How do I declare an array in Python?

Asked 2 years ago, Updated 2 years ago, 70 views

It's a very basic question. How do I declare an arrangement in Python?

Even if you search on Google, you can only see the list, but I wonder where they declare the arrangement.

python array

2022-09-22 22:12

1 Answers

I don't think you're asking the array module because you said it was a "primary question."

Python writes lists, not arrays.

Unlike the arrangement of C/C++, the list seems to have been named list because the length can vary dynamically and the type of element to store is independent.

How to write

variable = []

In fact, this is not a declaration, it is an assignment, but Python cannot hold a type fixed for a variable (dynamically transforming the type).

"This variable is only a list! There is no other type like an integer or a string!" It's impossible to decide together.


2022-09-22 22:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.