8 Answers

New AnswerUnlike list.append() method, np.append() is not 'inplace', which means that the original value of the numpy array won't change and you need to assign the new returned value of np.append(arr, e) to a variable. For example: List πΉ lst = [1, 2, 3] πΉ lst.append(4) >> [1, 2, 3, 4] Array (numpy) πΉ arr = np.array([1, 2, 3]) πΉ np.append(arr, 4) >> [1, 2, 3] You can solve this by assigning the new array to the same variable. πΉ arr = np.append(arr, 4)

YuGiMob I tried my previous solution and it also didn't work. I guess it is the numpy module that has changed where now it requires each elements to have the same length, and that the sololearn exercise is not updated. Anyway, your code seems to be correct. The input on test 4 has 4 lines (excluding the first line for determining the number of lines), and your code computes for 4 elements of means but the expected output only has three. Yeah, the last element in expected output 6.4 should have been 6 4. You can report this issue on [email protected]

YuGiMob I also tried it earlier on the average row test itself, the output seems to have a space after the first element of array. For example,: Output πΈ [1.5 2.5 4] Desired Output πΈ [1.5 2.5 4] Have you solved it?

YuGiMob I think it is caused by the np.append() method (not a sololearn bug). It makes all elements 'occupy' the same characters. For example if the array has 1.5 and 2.75, since there are 4 characters in 2.75, all elements including 1.5 will also occupy 4 characters (1.5 then a space) [1.5 2.5] What about using the list.append() method first when calculating the values then convert the final list to array before printing. This way the array will behave normally. [1.5 2.5]

I ended up with this: https://code.sololearn.com/cSz4aD5rQjuI/?ref=app It fails on the 4th check but this looks like an error of the check

noteve just wanted to let you know it has been fixed now and formatting is not required anymore