python - NameError: name 'result' is not defined -


I have written a very simple program in Python

  for the category I (1 , 1000): if (i% 3 == 0) and (i% 5 == 0): result + = i other: print ('sum is {}'. Format (result))  

When I try to compile the problem, I get an error.

  Name error: Name 'Result' is not defined  

This statement:

  is the result of + i =  

:

  result = result + I  

But, for the first time this statement has reached your loop, variable result is not defined, so the right hand of that assignment statement is evaluated Does not happen.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -