You should change the function to take the i
as input. And then move the summation out of the function.
total=0
def equation(i):
x=2+i
return x
for i in range(1,32): #represents no of days in January (31 days)
total += equation(i)
print total
Or you could do it this way with list comprehensions.
#OR
total += sum(equation(i) for i in range(1,32))
print total