I seem to not passed one of the tests, I don’t know why, but my code is outputting a float and something is wrong. Please help.
Why do you include the “keepdims” there? That results in the answer being an array instead of a scalar, which is what you want in this case.
2 Likes
I thought it was needed to broadcast correctly, but I guest since there isn’t broadcasting, it isn’t needed.
Getting rid of it worked, but why?
Did you read the documentation for numpy sum? I expiained it in my previous reply: using keepdims = True causes the result to be a numpy array, instead of a scalar.
Who said anything about broadcasting? What do you think that means?
1 Like
Oh, and a scalar is needed in this case, that makes sense
I just was scared I would forget something, I just wasn’t thinking about that part and fully getting the knowledge, but now I do.
1 Like