Skip to content

Instantly share code, notes, and snippets.

@mightywombat
Created December 29, 2020 02:52
Show Gist options
  • Save mightywombat/2eb78e8345d3bc3e6900410adcd85d49 to your computer and use it in GitHub Desktop.
Save mightywombat/2eb78e8345d3bc3e6900410adcd85d49 to your computer and use it in GitHub Desktop.
def count_substring(string, sub_string):
count = 0
for i, value in enumerate(string):
if string[i:i+len(sub_string)] == sub_string:
count += 1
return count
#print("match at string[" + str(i) + "]")
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment