Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I have the 2 lists with info:

test1 = [1,2,3,4]

test2 = ["a","b","c","d"]

I want to print it in the following order: The first item of the 1st array stays with the 1st item of the 2nd array, the 2nd of the 1st array stay with the 2nd of the 2nd array, and so on. I want to print it in this way:

[('a', 1),  ('b', 2), ('c', 3), ('d', 4)]

How can I do this? 

1 Answer

0 votes
by (36.8k points)
edited by

This is the solution:

list(zip(test2, test1))

If you are a beginner and want to know more about Python the do check out the Data Science with Python Course 

Browse Categories

...