0

Is there any simple way to declare a null array of size n in python?

23rd Jun 2018, 2:23 PM
Akshaya Rajesh
Akshaya Rajesh - avatar
3 Answers
+ 5
import numpy as np arr = np.empty(10) print(arr) # the array is printed similar to a zero-like one, but in fact its values are not being initialized -- array-wise it is like it's full of 'None's
23rd Jun 2018, 9:03 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 2
array = [None] * n #But I don't think you really want to declare the size of a list in Python in advance, since you can use the append method of list
23rd Jun 2018, 2:30 PM
æŽç«‹ćš
+ 1
array=[]
23rd Jun 2018, 3:12 PM
Sahil Danayak
Sahil Danayak - avatar