Checkpoint 27.8.1.
First, let’s not worry about filtering out the bad values or finding the average. Let’s just calculate the total of the values in the list.
We will write the code in a function
getRealAvg
so that it is easier to test with different possible lists of data - we will get a different list for each month of data, so we need our program to work correctly for any list it is given. This function should add all of the values in rainList
to the variable sumRain
which will be the answer it returns.
(Right now the name
getRealAvg
is not accurate because we are not calculating the average yet, but it will be an appropriate name when we complete the program.)
While working on the program, you may want to use codelens or print out information so you can see what is happening as the code runs. You can also comment out one of the two tests to focus on the other one.