Stuck with a python logic

As an FYI, you should paste your Python code using the Preformatted Text option. Just highlight your pasted text and click </> in the toolbar above.

Yes, but I don’t think that’s what you need here. As @awilliams said, you can wrap your if statement within your for loop.

However, if you wanted to iterate through both lists simultaneously you would use:
for i, j in zip(list1, list2):
This would essentially get you paired values list1[0]/list2[0], list1[1]/list2[1], etc.

1 Like