Answers for "how to pair up two lists in python"

1

how to pair up two lists in python

x = [1, 2, 3]
y = [4, 5, 6]
l = list(zip(x, y))
print(l)
>>> [(1, 4), (2, 5), (3, 6)]
Posted by: Guest on October-10-2021
0

python pair two lists into a dictionary

#Two lists
keys = ["Foo", "Bar", "Done"]
values = [1, 6, 9]
  
d = dict(zip(keys, values))
d
>>>{'Foo': 1, 'Bar': 6, 'Done': 9}
Posted by: Guest on September-10-2021

Code answers related to "how to pair up two lists in python"

Python Answers by Framework

Browse Popular Code Answers by Language