Unable to solve the problem. My answer is not correct. Help me to understand
Task:wWrite a function that takes a NumPy array and returns its shape, dimensions, and size, collected in a string
import numpy as np
def collect_info(array):
shape = (2, 2, 3)
dimensions = 3
size = 12
return f'Shape: {shape}; dimensions: {dimensions}; size: {size}'
collect_info()
>Solution :
import numpy as np
def collect_info(array):
shape = array.shape
dimensions = array.ndim
size = array.size
return f'Shape: {shape}; dimensions: {dimensions}; size: {size}'
my_array = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
result = collect_info(my_array)
print(result)
I hope this helps!