![Python 多项判断_倒序](//dev-img.mos.moduyun.com/20231023/2156beb6-9697-4e61-8779-678b2176f779.png)
list_1 = [1,2,3]
list_2 = list_1[::-1] # 倒序
'''判断条件 加括号'''
list_index = []
for index in range(3):
if ( list_1[index]>1 ) & ( list_2[index]<2 ):
list_index.append( index )
print( list_index )
list_index = []
for index in range(3):
if ( list_1[index]>1 ) | ( list_2[index]<2 ):
list_index.append( index )
print( list_index )
'''不加括号 错误'''
list_index = []
for index in range(3):
if list_1[index]>1 & list_2[index]<2:
list_index.append( index )
print( list_index )
list_index = []
for index in range(3):
if list_1[index]>1 | list_2[index]<2:
list_index.append( index )
print( list_index )
'''
[2]
[1, 2]
[1, 2]
[2]
'''