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>If as you mention, the functionality inside the loop is the same for all three arrays, then why not factoring it into a single function and call such function on your three arrays?</p>

<p>For example:</p>

<pre class="lang-py prettyprint-override"><code>def my_functionality(array):
    for loop in array:
        loop = some_value

...

my_functionality(a)
my_functionality(b)
my_functionality(c)
</code></pre>

python arrays for-loop