-3
List1 = ['3','1','2']
List2 = ['0','1','0']
List3 = ['string1','string2','string3']

I want to do

 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'

Context : https://repl.it/@glasgowm1498/GreenyellowKnowingCommands

Mazdak
  • 105,000
  • 18
  • 159
  • 188
user3820095
  • 19
  • 1
  • 3
  • 1
    Possible duplicate of: https://stackoverflow.com/questions/1663807/how-to-iterate-through-two-lists-in-parallel. Just use three lists instead of two. – Mazdak Mar 18 '18 at 10:58
  • Please clarify what you are trying to accomplish. Your code comments are too ambiguous. – Rory Daulton Mar 18 '18 at 11:03

1 Answers1

0

I would use python's build in zip function documentation

for item1, item2, item3 in zip(list1, list2, list3):
    if item1 == item2:
        print(item3)

Hope it helps!

hodisr
  • 314
  • 2
  • 12
  • 1
    Thanks! I was using a method of that already but didn't realise you could use it for 3 items. Thanks for actually responding instead of moaning about formatting and downvoting like what seems prevalent in newbie questions here – user3820095 Mar 18 '18 at 12:59