I don't understand this error message


#1

Instruction: We’re trying to figure out how much it rained in the past year! Update the annual_rainfall variable to include the values from September to December.

My answer:

january_rainfall = 1
annual_rainfall += january_rainfall
febuary_rainfall = 2
annual_rainfall += febuary_rainfall
march_rainfall = 3
annual_rainfall += march_rainfall
april_rainfall = 4
annual_rainfall += april_rainfall
may_rainfall = 5
annual_rainfall += may_rainfall
june_rainfall = 6
annual_rainfall += june_rainfall
july_rainfall = 7
annual_rainfall += july_rainfall
august_rainfall = 8
annual_rainfall += august_rainfall
september_rainfall = 9
annual_rainfall += september_rainfall
october_rainfall = 10
annual_rainfall += october_rainfall
november_rainfall = 11
annual_rainfall += november_rainfall
december_rainfall = 12
annual_rainfall += december_rainfall

But it says that name ‘annual_rainfall’ is not defined, what am I supposed to do ?


#2

defining annual_rainfall

this:

annual_rainfall += january_rainfall

is a shorthand for:

annual_rainfall = annual_rainfall + january_rainfall

so annual_rainfall needs be defined, otherwise the annual_rainfall on the right hand side of the equal sign is undefined, which produces an error


#3

I rewrote the code again:

annual_rainfall = 0
january_rainfall = 1
annual_rainfall += january_rainfall
febuary_rainfall = 2
annual_rainfall += febuary_rainfall
march_rainfall = 3
annual_rainfall += march_rainfall
april_rainfall = 4
annual_rainfall += april_rainfall
may_rainfall = 5
annual_rainfall += may_rainfall
june_rainfall = 6
annual_rainfall += june_rainfall
july_rainfall = 7
annual_rainfall += july_rainfall
august_rainfall = 8
annual_rainfall += august_rainfall
september_rainfall = 9
annual_rainfall += september_rainfall
october_rainfall = 10
annual_rainfall += october_rainfall
november_rainfall = 11
annual_rainfall += november_rainfall
december_rainfall = 12
annual_rainfall += december_rainfall

but the system asked if I have added all of the remaining months to the variable annual_rainfall


#4

i would need to debug that one in the exercise, please share the url of the exercise


#5

https://www.codecademy.com/courses/learn-python/lessons/python-syntax/exercises/update-variables?action=resume_content_item


#6

this is the code the exercise starts with:

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

you can’t change the values of month_rainfall (where month is January till December), the exercise validation doesn’t tolerate it.

just add what the exercise asks