You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

43 lines
716 B

# test for-else statement
# test optimised range with simple else
for i in range(2):
print(i)
else:
print('else')
# test optimised range with break over else
for i in range(2):
print(i)
break
else:
print('else')
# test nested optimised range with continue in the else
for i in range(4):
print(i)
for j in range(4):
pass
else:
continue
break
# test optimised range with non-constant end value
N = 2
for i in range(N):
print(i)
else:
print('else')
# test generic iterator with simple else
for i in [0, 1]:
print(i)
else:
print('else')
# test generic iterator with break over else
for i in [0, 1]:
print(i)
break
else:
print('else')