a = [1, 2]
for i in range(len(a)):
if a[i] < 2 <= a[i + 1]:
print('True')
print('第一次循环完成')
for i in range(len(a)):
if a[i] < 3 <= a[i + 1]:
print('True')
print('第二次循环完成')
结果:
True
第一次循环完成
Traceback (most recent call last):
File "C:/Desktop/test/t3.py", line 7, in <module>
if a[i] < 3 <= a[i + 1]:
IndexError: list index out of range