Why Can't I Add Multiple Values to a Variable?


#1

Why can’t I write the whole update of the variable in one line? Like this- annual_rainfall+=september_rainfall+=october_rainfalll+=november_rainfall ,ect.


FAQ: Learn Python - Python Syntax - Updating Variables
#2

Hi @gaya.y,

When adding multiple values together, you need to use only a single plus sign (+). When assigning a variable a new value, you use a += assignment operator (which is the same as foo = foo + ...). So, instead of assigning every variable a new value try assigning annual_rainfall to september_rainfall plus october_rainfall, and so on.