In the Code used, I have the values arr1 as 25,26 and arr2 values as A,B and the number of values are always equal in arr1 and arr2

For the following code:

for i in arr1.split(","):
print i //prints 25 and 26

If i want to map the values of arr1 & arr2, is it not possible to get the values of arr2 in the same loop ?
Nov 28, 2018 in Python 615 views

## 1 answer to this question.

You can use the enumerate function and loop through a list in order to get both its numerical index and its value. The code can be written as :

array1 = arr1.split(',')
array2 = arr2.split(',')
for i,value in enumerate(array1):
print value, array2[i]

This will give the following output:

25 A
26 B
• 13,300 points

## How do I obtain the index list in a NumPy Array of all the NaN values present using Python?

Hi, it is pretty simple, to be ...READ MORE

## Is it possible to create an array with all values as zero in python?

You can use  np.zeros(4,3) This will create a 4 ...READ MORE

## What is an array in Python? How to declare it?

Python doesn't have a native array data ...READ MORE

+1 vote

## How to print array/ list without brackets in python?

print(*names, sep = ', ') This is what ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE