Advertisement
NightRaven97

Number of times a substring occurs in a string

May 11th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. #Program to find the number of times a substring occurs in a given string
  2. text=raw_input("Enter the text:")
  3. count=0
  4. length=len(text)
  5. for i in range(0,length):
  6.     if text[i]=='E' and text[i+1]=='A' and text[i+2]=='T':
  7.         count+=1
  8. print count
  9. raw_input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement