In step 8 of the Life Expectancy By Country project ( Quartiles, Quantiles, and Interquartile Range) it was required to copy and paste the following code:
However in my code the color of the logical operators (< >=) is not white, it is orange. And after running it gets an error (ValueError: Lengths must match to compare). What should I do?
I wouldn’t worry about that; it’s likely just that the colour scheme for the learning environment has changed since the instruction snapshot was taken.
The error would suggest there’s an issue with at least one of the values on either side of your comparison operator. Perhaps you should
print them out and check them?
I tried what you said. I checked it each variable and it is fine. However the comparison does not work.
If you have an error saying the lengths need to be the same, have you checked the lengths of the things you’re using? Seems like the obvious thing to look at don’t you agree?
And, you did things earlier in your code, just because an error happens at one location doesn’t mean that’s where the mistake is.
Getting yourself a crystal clear idea of what it is your code is supposed to be doing will help you as well. If you’re just copying and then get an error then it’s not such a big surprise if it’s difficult to fix. So you’d want to know what your program is supposed to do all the way through, and you’d want to know what the behaviour is for all the operations that you’re using to describe those actions.