Skip to content
Advertisement

How do I get an empty list of any size in Python?

I basically want a Python equivalent of this Array in C:

JavaScript

but in python I declare an array like:

JavaScript

and the problem is I want to assign random slots with values like:

JavaScript

but I can’t do that with Python, since the Python list is empty (of length 0).

Advertisement

Answer

If by “array” you actually mean a Python list, you can use

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement