How to loop through 3 different arrays by using a single for loop in Python
<p>I have 3 different arrays:</p>

<pre><code>a = (x, y, z)
b = (p, q)
c = (r, s)
</code></pre>

<p>I need to loop through all this arrays. Presently I am using the below method:</p>

<pre><code>for loop_a in a:
  loop_a = some_value

for loop_b in b:
  loop_b = some_value

for loop_c in c:
  loop_c = some_value
</code></pre>

<p>How I can do this using a single for loop and iterate through all the arrays. Functionality inside the loop is same for all. I need an efficient way to do this. I checked many other already answered questions, but couldn't find a fitting answer.</p>

<p>Why not just this?</p>

<pre><code>for array in [a, b, c]:
    for element in array:
        ...
</code></pre>

<p>or</p>

<pre><code>def f (x) :
    ...

for e in a:
    e = f(e)
for e in b:
    e = f(e)
for e in c:
    e = f(e)
</code></pre>

python arrays for-loop