2017-05-11 3:53 GMT+02:00 Rafael Skovron <rskov...@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): > > j=0 > > while j < i: > > print(j, end = " ") > > j += 1 > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor >
Hi, 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). George _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor