Data science average of rows
Data Science - Average of Rows In a matrix, or 2-d array X, the averages (or means) of the elements of rows is called row means. Task Given a 2D array, return the rowmeans. Input Format First line: two integers separated by spaces, the first indicates the rows of matrix X (n) and the second indicates the columns of X (p) Next n lines: values of the row in X Output Format An numpy 1d array of values rounded to the second decimal. 2 2 1.5 1 2 2.9 Sample Output [1.25 2.45] My Code: import numpy as np n, p = [int(x) for x in input().split()] my_list = [] for i in range(n): my_list.append(list(float(x) for x in (input().split()))) my_list_ar = np.array(my_list) my_list_ar.reshape(n, p) print(np.around((my_list_ar.mean(axis=1)), decimals=2)) Input 3 2 1 2 1 0.5 1 0.3 Your Output [1.5 0.75 0.65] Expected Output [1.5 0.75 0.65] It says the error is because there is a space between 1.5 and 0.75