-7

I have this 2 lists with info:

test1 = [1,2,3,4]

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

I want to print this in the following order: The first item of the first array stays with the first item of the second array, the second of the first array stay with the second of the second 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? I tried string formats but it didn't work.

Ismael Padilla
  • 5,246
  • 4
  • 23
  • 35
  • is your list `test2` a list of variables or strings? in the definition, it seems to be variables since there's no quotes around them – Energya Dec 19 '19 at 15:14

1 Answers1

2

This is the simplest solution:

list(zip(test2, test1))
Riccardo Bucco
  • 13,980
  • 4
  • 22
  • 50