Write Python3 code to demonstrate working of Add list elements to tuples list Using list comprehension + "*" operator


Topic: Write Python3 code to demonstrate working of Add list elements to tuples list Using list comprehension + "*" operator

Solution

test_list = [(5, 6), (2, 4), (5, 7), (2, 5)] 
print("The original list is : " + str(test_list)) 
sub_list = [7, 2, 4, 6] 
res = [(*sub, *sub_list) for sub in test_list] 
print("The modified list : " + str(res)) 



List all Python Programs