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>You could also use lambda function (or just normal function) with map function. Map runs the function given to it as first argument for each value of iterable given as second argument and returns iterator.</p>

<p><a href="https://docs.python.org/3/library/functions.html#map" rel="nofollow">Python map documentation</a> </p>

<pre><code>list1 = range(1,10)
list2 = range(1,13, 2)
list3 = range(1,15, 3)

some_value = 123

lambda_func = lambda x: some_value*x

list1 = map(lambda_func, list1)
list2 = map(lambda_func, list2)
list3 = map(lambda_func, list3)

print("list1: " + str(list1))
print("list2: " + str(list2))
print("list3: " + str(list3))
</code></pre>

python arrays for-loop