human
Count strings that end with the given pattern | Function that return true if str1 ends with pat.
Pattern is larger in length than the str1ing.
We match starting from the end while patLen is greater than or equal to 0..
If at any index str1 doesn 't match  with pattern.
If str1 ends with the given pattern.
Function to return the count of required str1ings.
If current str1ing ends with the given pattern.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to count strings that end with the given pattern and the other steps required.
 def endsWith ( str1 , pat ) :
	patLen = len ( pat )
	str1Len = len ( str1 )
	if ( patLen > str1Len ) :
		return False
	patLen -= 1
	str1Len -= 1
	while ( patLen >= 0 ) :
		if ( pat [ patLen ] != str1 [ str1Len ] ) :
			return False
		patLen -= 1
		str1Len -= 1
	return True
def countOfstr1ings ( pat , n , sArr ) :
	count = 0
	for i in range ( n ) :
		if ( endsWith ( sArr [ i ] , pat ) == True ) :
			count += 1
	return count
pat = " ks "
n = 4
sArr = [ " geeks " , " geeksforgeeks " , " games " , " unit " ]
print ( countOfstr1ings ( pat , n , sArr ) )