我有两份清单
list1 = [1, 3, 5, 8]
list2 = [7, 10, 12]
还有一些破坏int值
switchValue = 4
我需要反复浏览
list1
而其元素的价值小于
switchValue
,然后迭代整个
list2
1.我知道如何使用
if
和
break
声明
else
分支,但我正在研究如何在Python2.7中实现这一点的一些更优化(推荐)的方法,因为这些列表将非常大。此外,还会对列表进行排序。
result
应该是
1, 3, 7, 10, 12
list1 = [1, 3, 5, 8]
list2 = [7, 10, 12]
switchValue = 4
for i in list1:
if i < switchValue:
print(i)
else:
for j in list2:
print(j)
break