-1

I have two for loops to get the result as below.

First loop:

 for row1 in value1:
     print(row1)

The result is:

    A
    B
    C

Second loop:

 for row2 in value2:
     print(row2)

The result is:

    A
    B
    C

The result is expected as below using both the loops:

A A
B B
C C

I have tried using nested loops:

for row1 in value1:
    for row2 in value2:
       print(row1, row2)

The result is coming in as Cartesian values:
A A
A B
A C
B A
B B
B C
C A
C B
C V

What can I try next?

halfer
  • 19,824
  • 17
  • 99
  • 186
Jim Macaulay
  • 4,709
  • 4
  • 28
  • 53

1 Answers1

2
value1=['A','B','C']
value2=['A','B','C']

for x,y in enumerate(value1):
    print(value2[x],y)

A A
B B
C C

Or

for x,y in zip(value1,value2):
    print(x,y)

A A
B B
C C
Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44