As you see, I created and array but I specify a tuple as the third argument. I thought that I would simply do this code to get the shape.
X.shape()
But I receive an error stating that a tuple was not callable. I am using numpy v1.23 with python 3.10.4 and inside the console of Spyder 5.
Any suggestion to get that result?
Thank you in advance for your help. Mario
I Google it and I never find the answer I am looking for
CodePudding user response:
X.shape
is not a method but a class attribute and hence not callable, i.e. cannot be called like a function with parentheses. You can just access it like any other class attribute.
import numpy as np
arr = np.random.randint(1, 7, (10, 3))
print(arr.shape)
Expected output:
(10, 3)