I am look like to be able to iterate over two arrays in parallel (or with only one for loop).
Here is my script I tried ...
#!/usr/bin/env python
list1 = [ 'one', 'two', 'three' ]
list2 = [ 'I', 'II', 'III', 'IV', 'V' ]
for word in list1:
print word + " from list1"
for roman in list2:
print roman + " from list2"
for ( word, roman ) in (list1 list2):
if word:
print word + " from list1"
if roman:
print roman + " from list2"
But is obviously incorrect as I get a syntax error:
File "./twoarr.py", line 12
for ( word, roman ) in (list1 list2):
^
SyntaxError: invalid syntax
I am trying to get output that would look like this:
one from list1
I from list2
two from list1
II from list2
three from list1
III from list2
IV from list2
V from list2