when we have to add in python via for loops then we have to type something like this:
>>> list(range(1,10))
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> total=0
... for element in range(1,10) :
... total+=element
>>> print(total)
45
But i tried doing something else, i did not defined total in the benign and later just defined total as (total=element
). and when i print total
then every time 4
is coming no matter which number sequence i have. Can any one explain the reason that why every time 4
is coming?