0
a =['1','2','3']
b =['A','B','C']

for i in a:
   print(i)
output:
1
2
3

for i in b:
  print(i)

output:
A
B
C

I want to map 1 , A 2, B 3, C

so that i can store the value in DB in one for loop parallely

for i , n in a,b:
  print i,n 

This is not allowed

Nikki Ganju
  • 141
  • 1
  • 11

1 Answers1

2

Use the zip() builtin.

a = ['1','2','3']
b = ['A','B','C']

for i, n in zip(a, b):
    print(i, n)
AKX
  • 152,115
  • 15
  • 115
  • 172