Why January to June rainfall not January to August?

Why january_to_june_rainfall and not january_to_august_rainfall instead?
I cannot solve this exercise, please help!

Hi Alexandra, would you mind telling us more about how you’re stuck? If you give us as much context as possible, it makes it a lot easier to try and help you out! This guide might help you to ask a good question.

1 Like

I may have been a bit unclear in my explanation, I’ll update it to be more thorough with the info below!

We start with the code below:

january_to_june_rainfall = 1.93 + 0.71 + 3.53 + 3.41 + 3.69 + 4.50
annual_rainfall = january_to_june_rainfall

july_rainfall = 1.05
annual_rainfall += july_rainfall

august_rainfall = 4.91
annual_rainfall += august_rainfall

september_rainfall = 5.16
october_rainfall = 7.20
november_rainfall = 5.06
december_rainfall = 4.06

The very first line of code, january_to_june_rainfall = 1.93 + 0.71 + 3.53 + 3.41 + 3.69 + 4.50, assigns the result of that addition to the variable named january_to_june_rainfall.
After that, three examples of using the += operator are given to give you an idea of how to update an existing variable’s value, annual_rainfall.
September through December, then, are the months we haven’t added to the existing variable’s value, which is the goal of the exercise.


Thank you very much for your explanation. I am still trying to understand the whole thing.

Are those values random by the way? I tried to write the same thing with this only exception:

january_to_august_rainfall = 1.93 + 0.71 + 3.53 + 3.41 + 3.69 + 4.50 + 5 + 3.42
annual_rainfall = january_to_august_rainfall

It didn’t work :frowning:

1 Like

Thank you for the advice and sorry for not being clear this time!

1 Like

I’m trying to figure out as well how did you come up with the values of 1.93 + 0.71 + 3.53 + 3.41 + 3.69 + 4.50 + 5 + 3.42 for the annual_rainfall. Because on the instructions it didn’t specify what the values are for the annual_rainfall and every month it rained. Do we just make up the amount ourselves?


We do need more context for this question. Please post a link to the exercise page. Thanks.

Copy the URL in the location bar above the lesson and paste it into a post.

1 Like

[Updating Variables]


1 Like

Upon resetting the exercise we can see that all the data is provided, so nothing random, as it were.

The exercise asks that we add the last for months to the accumulator variable.

annual_rainfall += september_rainfall
annual_rainfall += october_rainfall
annual_rainfall += november_rainfall
annual_rainfall += december_rainfall
1 Like

How does the amount of rainfall get calculated in this code?

By accumulation in a variable.

1 Like