str1
is a string in which the search is to be performed (the haystack). str2
is the string to be found (the needle). count
will count the number of occurences of str2
in str1
.
The code below gives me a syntax error in the last line. Please suggest changes.
str1 = raw_input()
str2 = raw_input()
count = 0
for i in range(0,len(str1)) :
if ( str1.find(str2, i, i+len(str2))) :
count=count+1
print count