A lot of the comments focused on the subject line, the difference between list and numpy array. But the example is all about the display of a numpy array.
Your example:
In [272]: x = np.array(([1,2,2], [1,4,3], [1,2,9]))
...: x = np.full(x.shape, 10)
In [273]: x
Out[273]:
array([[10, 10, 10],
[10, 10, 10],
[10, 10, 10]])
In [274]: print(x)
[[10 10 10]
[10 10 10]
[10 10 10]]
That print is the str display of an array. Note the missing commas. The repr display includes the commas and word 'array'
In [275]: print(repr(x))
array([[10, 10, 10],
[10, 10, 10],
[10, 10, 10]])
The display of a list:
In [276]: x.tolist()
Out[276]: [[10, 10, 10], [10, 10, 10], [10, 10, 10]]
The 'duplicate' that focuses on list versus array:
Python: Differences between lists and numpy array of objects
Some examples from the comments:
In [277]: np.array()
Traceback (most recent call last):
File "<ipython-input-277-e4f3b47dc252>", line 1, in <module>
np.array()
TypeError: array() missing required argument 'object' (pos 1)
Making a 2d array without any elements:
In [278]: np.array([[]])
Out[278]: array([], shape=(1, 0), dtype=float64)
Making a 0d array with 1 element:
In [279]: np.array(34)
Out[279]: array(34)
In [280]: np.array(34).shape
Out[280]: ()
Arrays can a wide range of dimensions and shape, from 0d up (max 32). Depending on where you come from dimensions other than 2 can be hard to picture.
The display of arrays and lists generally match in the nesting of brackets.
array()around is is theprint()call. When you print an array, therepris to just display the contents as a list of listsarray()does not==[[]]. You are merely seeing how numpy.ndarray objects are printed. Don't worry too much about what you see when youprintsomething. Check thetypeof the object. You'll see your code produces anumpy.ndarrayobject, not alist, if that is what you are afraid of