Back

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

I need a python equivalent of this below statement in C:

int a[x];

But, In the case of python, I can declare an array like this:

a=[]

furthermore, the issue is I need to allot random slot with values like: 

a[4]=1

however, I can't do it with python, since the array is unfilled.

1 Answer

0 votes
by (26.4k points)

On the off chance that by "array" you really mean a Python list, you can utilize

a=[0]*10

or

a=[None]*10

Interested to learn python in detail? Come and Join the python online course.

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
asked Jul 8, 2019 in Python by Sammy (47.6k points)

Browse Categories

...