Lichen

tests/for.py

1038:e3d77b4d9fa8
5 months ago Paul Boddie Merged changes from the trailing-data branch. value-replacement
     1 l = [1, 2, 3]     2      3 # Test else clause.     4      5 for i in l:     6     print i             # 1     7                         # 2     8                         # 3     9 else:    10     print 4             # 4    11     12 # Test break versus else clause.    13     14 for i in l:    15     print i             # 1    16                         # 2    17     if i == 2:    18         break    19 else:    20     print 3    21     22 # Test StopIteration in loop.    23     24 try:    25     for i in l:    26         print i         # 1    27                         # 2    28         if i == 2:    29             raise StopIteration    30     else:    31         print 3    32     33 except StopIteration:    34     print "stopped"     # stopped