0 votes
1 view
in Python by (11.8k 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 (24.6k 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.8k points)
0 votes
2 answers
0 votes
1 answer
asked Jul 8, 2019 in Python by Sammy (47.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...