human
Count of substrings of a string containing another given string as a substring | Function to store all substrings of S.
Stores the substrings of S.
Pick start point in outer loop and lengths of different strings for a given starting point.
Return the array containing substrings of S.
Function to check if a is present in another string.
Check if target is in the str or not.
Function to count the subof S containing T in it as substring.
Store all substrings of S in the array v [ ].
Store required count of substrings.
Iterate through all the substrings of S.
If T is present in the current substring , then increment the ans.
Print the answer.
Driver code.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to count of substrings of a string containing another given string as a substring and the other steps required.
 def subString ( s , n ) :
	v = [ ]
	for i in range ( n ) :
		for len in range ( 1 , n - i + 1 ) :
			find = s [ i : i + len ]
			v . append ( find )
	return v
def IsPresent ( str , target ) :
	if ( target in str ) :
		return 1
	return - 1
def countSubstrings ( S , T ) :
	v = subString ( S , len ( S ) )
	ans = 0
	for it in v :
		if ( IsPresent ( it , T ) != - 1 ) :
			ans += 1
	print ( ans )
if __name__ == ' _ _ main _ _ ' :
	S = " dabc "
	T = " ab "
	countSubstrings ( S , T )