Mohammad Faizan Khan Mohammad Faizan Khan - 3 months ago 12
Python Question

How to run two loop simeltanously in one loop in python

Is there any way available to put two loops in one? I have:

for getFeature in layerNameValueGetObj.getFeatures():
for setFeature in layerNameValueSetObj.getFeatures():

I want to run
under one loop. How can I do this?

I don't want to nest them, I want to get both loop columns at a time.


You can use zip

for a, b in zip(list_a, list_b): 
    print a, b