# Write a Python program to accept two lists and merge the two lists into list of tuple.def merge_lists_to_tuples(list1, list2): merged_list = list(zip(list1, list2)) return merged_listlist1 = input("Enter the first list of elements (separated by spaces): ").split()list2 = input("Enter the second list of elements (separated by spaces): ").split()result = merge_lists_to_tuples(list1, list2)print("Merged list of tuples:", result)
1 Comments
# Write a Python program to accept two lists and merge the two lists into list of tuple.
ReplyDeletedef merge_lists_to_tuples(list1, list2):
merged_list = list(zip(list1, list2))
return merged_list
list1 = input("Enter the first list of elements (separated by spaces): ").split()
list2 = input("Enter the second list of elements (separated by spaces): ").split()
result = merge_lists_to_tuples(list1, list2)
print("Merged list of tuples:", result)