Sobes.tech
Junior

How to combine two lists into a list of tuples?

sobes.tech AI

Answer from AI

Using the zip() function.

# Example lists
list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']

# Combining lists into a list of tuples
result = list(zip(list1, list2))

# Output the result
# print(result) # Will output [(1, 'a'), (2, 'b'), (3, 'c')]
How to combine two lists into a list of tuples… - sobes.tech