This question is somewhat similar to this question, but different in that it entails multiple lists:
I have three lists:
a = [1, 2, 3, 4, 5, 6, 7]
b = ['ball', 'cat', 'dog', 'elephant', 'baboon', 'crocodile']
c = [6, 3, 5, 4, 3, 2, 1]
I am iterating through the list as follows:
for (x, y, z) in itertools.product(a, b, c):
print("The combination is: " + str(x) + ", " + y + ", " str(z))
I would like to add a condition which is expressed in the following pseudo-code:
for (x, y, z) in itertools.product(a, b, c):
if x != z:
print("The combination is: " + str(x) + ", " + y + ", " str(z))
if x == z:
skip to the next element in list "a" without skipping elements of "b" & "c" # this is pseudo code
How could I accomplish this? Is there a function in itertools that could be used to accomplish this?