【发布时间】:2018-03-18 10:54:47
【问题描述】:
List1 = ['3','1','2']
List2 = ['0','1','0']
List3 = ['string1','string2','string3']
我想做
if List1[i] > 3 and List2[i] = 0 # i = iterating through list1/2 at the same time and comparing them
print(List3[i]) # i = being the index number found when the if statement is met
#expected output = 'string1'
上下文:https://repl.it/@glasgowm1498/GreenyellowKnowingCommands
【问题讨论】:
-
可能重复:stackoverflow.com/questions/1663807/…。只需使用三个列表而不是两个。
-
请说明您要完成的工作。您的代码 cmets 太模棱两可了。
标签: python python-3.x list compare