[Tutor] While Loop Question
george at fischhof.hu
Thu May 11 04:21:43 EDT 2017
2017-05-11 3:53 GMT+02:00 Rafael Skovron <rskovron at gmail.com>:
> Sorry I left out the indents in my previous email. It seems like j is
> always reset to zero. Why does j vary?
> Are there two different instances of j going on?
> for i in range(1, 5):
> while j < i:
> print(j, end = " ")
> j += 1
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
As there is a j = 0 statement in the for cycle, it will be set to 0 every
time the while cycle finishes. (The while cycle will then increment j, then
if j == i j will be set to 0 again).
More information about the Tutor