Guest User

PS3

a guest
Oct 17th, 2011
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. from string import *
  2.  
  3. key_s = raw_input("Enter the string you want to search. > ")
  4. target_s = raw_input("Enter what you are searching for. > ")
  5.      
  6. def count_sub_string_match_recursive(key_s, target_s):
  7.     recur_counter = 0
  8.     x = find(key_s, target_s)
  9.     while x >= 0:
  10.             key_s = key_s[:x] + key_s[x+len(target_s):]
  11.             recur_counter += 1
  12.             x = find(key_s, target_s)
  13.     return recur_counter
  14.            
  15.  
  16. print "This is how many times it shows up.", count_sub_string_match_recursive(key_s, target_s)
  17.  
Advertisement
Add Comment
Please, Sign In to add comment