human
Count words that appear exactly two times in an array of words | Returns count of words with frequency exactly 2..
Driver code"
How can the above be solved in Python?

Can you provide a code to count words that appear exactly two times in an array of words and the other steps required?
assistant
#Here is code to count words that appear exactly two times in an array of words and the other steps required.
 def countWords ( stri , n ) :
	m = dict ( )
	for i in range ( n ) :
		m [ stri [ i ] ] = m . get ( stri [ i ] , 0 ) + 1
	res = 0
	for i in m . values ( ) :
		if i == 2 :
			res += 1
	return res
s = [ " hate " , " love " , " peace " , " love " , " peace " , " hate " , " love " , " peace " , " love " , " peace " ]
n = len ( s )
print ( countWords ( s , n ) )