The else clause in a for loop (or a while loop) should be read as "if no break:"
André On Mon, Nov 21, 2011 at 3:17 PM, Jurgis Pralgauskis < jurgis.pralgaus...@gmail.com> wrote: > Hello, > > does anyone know why this works without error on py 2.7? > > for x in [2, 5, 1]: print x > else: print "nonsense" > > the result: > 2 > 5 > 1 > nonsense > > > my students made such "composition", and I don't know myself why :) > > > -- > Jurgis Pralgauskis > tel: 8-616 77613; > Don't worry, be happy and make things better ;) > http://kompiuterija.pasimokom.lt > _______________________________________________ > Edu-sig mailing list > Edu-sig@python.org > http://mail.python.org/mailman/listinfo/edu-sig >
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig