Deleted


#1

From The Variance

The top code is the answer I got by clicking "get code."
The bottom code is what I entered, getting this error: "code grades_variance([3, 5, 7, 5, 5, 1, 3]) returned 0.1865889213 instead of the expected: 3.2653061224."
It seems very similar to the answer Codecademy gave, so I’m not sure where I went wrong.

I tried it again and made sure there were 4 spaces indentation and got the error: “grades_variance([5, 2, 9, 4, 3, 3, 4]) returned 0.0728862974 instead of the expected: 4.4897959184” (but I got the same output)


#2

In the very last example the return statement is indented too much. It should not be inside the loop block.


#3

Ohh wow how did I miss that. Thanks


#4

Something we never quite lose, even over a long time is confirmation bias. For me it’s a constant fight. Code should work, looks good, &c. The error can be blatant or subtle, syntax or logic, but for our bias (it’s human, so don’t wear this like a cauldron) we don’t see it. Over time we do get better at spotting mistakes.

Reading, and especially writing code teaches our brain to parse it. Parsing and backwards syntax checking (check lines from bottom to top) is one method to identify weaknesses and errors. There is no cure for human error, so expect to make lots of mistakes and get plenty of practice finding them. It is a natural way to learn. Happy coding!


#5

Fighting the good fight :muscle:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.