## occurences of substring in a String python

### Description

```python program to get a String and Substring and count the occurrence of substring in string.
Input:
entertainment
en
Ouput:
2```

### Solution

```s1=input("Enter a String:")
s2=input("Enter Substring:")
count=0
for i in range(0,len(s1)-len(s2)+1):
j=0
b=0
if(s1[i]==s2[j]):
k=i
while(j<len(s2)):
if(s1[k]!=s2[j]):
b=1
break
j=j+1
k=k+1
if(b==0):
count+=1
print(count)

```

### Explanation

`check whether first character of sub string is equal to any character in string. If it is equal, then check remaining characters are equal to the characters in substring.  else move to next character.`

#### Author - Ramesh P Natarajan

Learner, Professor, Technology Trainer, Software Developer and Content Marketer, very much passionate in the field of Software Application Development, Machine Learning and Search Engine Optimization.

### Interesting Pattern Programs: for more Patterns

```Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution```
```Input:
5
Output:
*
***
*****
*******
*********
*******
*****
***
*Solution```
```Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution```
```Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution```
```Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution```
```Input:
5
Output:
*********
*******
*****
***
*
***
*****
*******
*********Solution```