[Edu-sig] strange "else" behaviour (after "for", without "if")

Jurgis Pralgauskis jurgis.pralgauskis at gmail.com
Mon Nov 21 20:17:42 CET 2011


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


More information about the Edu-sig mailing list