1# test try-else statement 2 3# base case 4try: 5 print(1) 6except: 7 print(2) 8else: 9 print(3) 10 11# basic case that should skip else 12try: 13 print(1) 14 raise Exception 15except: 16 print(2) 17else: 18 print(3) 19 20# uncaught exception should skip else 21try: 22 try: 23 print(1) 24 raise ValueError 25 except TypeError: 26 print(2) 27 else: 28 print(3) 29except: 30 print('caught') 31 32# nested within outer try 33try: 34 print(1) 35 try: 36 print(2) 37 raise Exception 38 except: 39 print(3) 40 else: 41 print(4) 42except: 43 print(5) 44else: 45 print(6) 46 47# nested within outer except, one else should be skipped 48try: 49 print(1) 50 raise Exception 51except: 52 print(2) 53 try: 54 print(3) 55 except: 56 print(4) 57 else: 58 print(5) 59else: 60 print(6) 61 62# nested within outer except, both else should be skipped 63try: 64 print(1) 65 raise Exception 66except: 67 print(2) 68 try: 69 print(3) 70 raise Exception 71 except: 72 print(4) 73 else: 74 print(5) 75else: 76 print(6) 77