human
Count of pairs having each element equal to index of the other from an Array | Function to print the count of pair.
Iterate over all the elements of the array.
Increment the count.
Print the result.
Driver Code"
How can the above be solved in Python?

=====
Can you provide a code to count of pairs having each element equal to index of the other from an Array and the other steps required?
assistant
#Here is code to count of pairs having each element equal to index of the other from an Array and the other steps required.
 def countPairs ( N , arr ) :
	count = 0
	for i in range ( N ) :
		if ( i == arr [ arr [ i ] - 1 ] - 1 ) :
			count += 1
	print ( count // 2 )
if __name__ == " _ _ main _ _ " :
	arr = [ 2 , 1 , 4 , 3 ]
	N = len ( arr )
	countPairs ( N , arr )