Bruno Desthuilliers wrote: > Roel Schroeven a ecrit : > > Bruno Desthuilliers schreef: > > > >> stdazi a ecrit : > > > > > >>> for (i = 0 ; i < 10 ; i++) > >>> i = 10; > >> > >> > >> for i in range(10): > >> i = 10 > >> > >> What's your point, exactly ? > > > > > > In the first iteration, i is set equal to 10. Then, before starting the > > second iteration, i is incremented to 11; then the loop condition is > > checked and results in false. So the loop terminates after the first > > iteration. > > oops - my bad. But why would one do so when a break would do the trick: > for i in range(10): > break
After the C loop finishes, i is 11. After the python loop-with-break finishes, i is 0. That may effect later code. -- http://mail.python.org/mailman/listinfo/python-list