Dear experts
in learning the principles of Python I came across scope in the
control structure's section.
There I read the notion that variables createted inside a
control structute can't be seen or accessed from outside that
structure, Python would raise a Name Error.
However in for loops - also control structures - like in this
simple example:
for i in range(1,11):
sum = 0
sum += i
print(sum)
the print function "returns" the last number of range as
value of the variable sum created inside this for loop.
It should have raised a Name Error instead.
Could somebody please explain this discrepancy?
Marcus.
---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor