human
Can you provide a code to count the Number of matching characters in a pair of strings and the other steps required given the following:
Count the Number of matching characters in a pair of strings | Function to count the matching characters.
Traverse the string 1 char by char.
This will check if str1 [ i ] is present in str2 or not str2 . find ( str1 [ i ] ) returns - 1 if not found otherwise it returns the starting occurrence index of that character in str2.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to count the Number of matching characters in a pair of strings and the other steps required.
 def count ( str1 , str2 ) :
	c = 0 ; j = 0 ;
	for i in range ( len ( str1 ) ) :
		if str1 [ i ] in str2 :
			c += 1 ;
		j += 1 ;
	print ( " No . ▁ of ▁ matching ▁ characters ▁ are : ▁ " , c ) ;
if __name__ == " _ _ main _ _ " :
	str1 = " aabcddekll12 @ " ;
	str2 = " bb2211@55k " ;
	count ( str1 , str2 ) ;