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

Editing Python Class in Shell and SQLAlchemy -

uislider - In a MATLAB GUI, how does one implement a continuously varying slider from a GUIDE created .m file? -

python - Django Custom Admin Block For center of admin -