I basically want a Python equivalent of this Array in C:
int a[x];
but in python I declare an array like:
a = []
and the problem is I want to assign random slots with values like:
a[4] = 1
but I can't do that with Python, since the Python list is empty (of length 0).
a = [obj] * N
is that the same obj appears in each element of the array. If it a mutable obj, and you modify one item, all will be changed. ...But, for this example using integers (or any other immutable type), it makes no difference. Or, if you just assign to elements, it is not a problem either. (I mention it because I've done exactly that far too often :) ) – Henandchickens