The program is written in Python and performs the following operations:
The final output of the program will be the common tuples (if any) between the two lists "l1" and "l2". The list comprehension will return the common tuples, if any, in the two lists, by checking if each tuple in "l1" is equal to each tuple in "l2".
l1 = [('A' , 65), ('D' , 68), ('B' , 66)] l2 = [('D' , 68), ('C' , 67), ('A' , 65)] print("list 2 : " , l2) print("list 1 : " , l1) res = [i for i in l1 for j in l2 if i == j] print("Intersection of data records : ",res)
list 2 : [('D', 68), ('C', 67), ('A', 65)] list 1 : [('A', 65), ('D', 68), ('B', 66)] Intersection of data records : [('A', 65), ('D', 68)]
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions