human
Count of Substrings that can be formed without using the given list of Characters | Function to find the Number of sub - strings without using given character.
the freq array.
Count variable to store the count of the characters until a character from given L is encountered.
If a character from L is encountered , then the answer variable is incremented by the value obtained by using the mentioned formula and count is set to 0.
For last remaining characters.
Driver code"
How can the above be solved in Python?

Can you provide a code to count of Substrings that can be formed without using the given list of Characters and the other steps required?
assistant
#Here is code to count of Substrings that can be formed without using the given list of Characters and the other steps required.
 def countSubstring ( S , L , n ) :
	freq = [ 0 for i in range ( 26 ) ]
	for i in range ( n ) :
		freq [ ( ord ( L [ i ] ) - ord ( ' a ' ) ) ] = 1
	count , ans = 0 , 0
	for x in S :
		if ( freq [ ord ( x ) - ord ( ' a ' ) ] ) :
			ans += ( count * count + count ) // 2
			count = 0
		else :
			count += 1
	ans += ( count * count + count ) // 2
	return ans
S = " abcpxyz "
L = [ ' a ' , ' p ' , ' q ' ]
n = len ( L )
print ( countSubstring ( S , L , n ) )