0

I want to print two for loop's result in same line side by side

The code something like this, I know this code is not right:

import string

alpha = list(string.ascii_lowercase)
numb = list(range(1, 27, 1))

for i, j in alpha, numb:
    print('{} {}'.format(i, j))

The result I want:

1 a
2 b
3 c
4 d
....

1 Answers1

2

Adding zip should fix the issue.

import string

alpha = list(string.ascii_lowercase)
numb = list(range(1, 27, 1))

for i, j in zip(alpha, numb):
    print('{} {}'.format(i, j))
sushanth
  • 8,275
  • 3
  • 17
  • 28