- 列表遍历之坑
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = []
for i in list1:
i += 1
list2.append(i)
# print(i)
list1.remove(i)
print(list2)
print(list1)
输出结果:
list2=[2, 4, 6, 8, 10]
list1=[1, 3, 5, 7, 9]
- 找True
if not x or y:
print(1)
elif not x or not y and z:
print(2)
elif not x or y or not y and x:
print(3)
else:
print(4)
输出结果:True
解题:优先级顺序为 NOT、AND、OR。