Starting from basics, you can loop over one list and use a counter to index
into the same location on the matching target list:

x = ["a1","b1","c1"]
y = ["a2","b2","c2"]

i = 0
for item in x:
    print item, y[i]
    i += 1

Python provides an automatic way to do this approach:

for i, item in enumerate(x):
    print item, y[i]

The zip() function can create pair-wise items from two lists:

for item1, item2 in zip(x, y):
    print item1, item2

In python2, that has the downsize of creating potentially large temporary
lists in memory for you to iterate over. So there is a more efficient
generator option for very large lists :

from itertools import izip

for item1, item2 in izip(x, y):
    print item1, item2

Note in python 3, the zip() function becomes the efficient generator like
izip() in python 2.

Justin

On Thu, Sep 13, 2018, 7:41 AM Russell Pearsall <[email protected]> wrote:

> You can use zip (as in zipper) to combine the lists as you want.
>
> for g,t in zip(GEO,TGT):
>     Some_func(g, t)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/44587126-3879-4b44-90d1-13e15ec60c4b%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1tVf%3DQN4KyxbapTj_QOSHkNJ8S1NhWZ%3Dzc0B29S1Kfcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to