human
Count items common to both the lists but with different prices | function to count items common to both the lists but with different prices.
for each item of ' list1' check if it is in ' list2' but with a different price.
required count of items.
Driver program to test above"
How can the above be solved in Python?
assistant
#Here is code to count items common to both the lists but with different prices and the other steps required.
 def countItems ( list1 , list2 ) :
	count = 0
	for i in list1 :
		for j in list2 :
			if i [ 0 ] == j [ 0 ] and i [ 1 ] != j [ 1 ] :
				count += 1
	return count
list1 = [ ( " apple " , 60 ) , ( " bread " , 20 ) , ( " wheat " , 50 ) , ( " oil " , 30 ) ]
list2 = [ ( " milk " , 20 ) , ( " bread " , 15 ) , ( " wheat " , 40 ) , ( " apple " , 60 ) ]
print ( " Count ▁ = ▁ " , countItems ( list1 , list2 ) )