Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
33 lines (25 loc) · 837 Bytes

File metadata and controls

33 lines (25 loc) · 837 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import re #Regular Expressions Module
'''
..Function compile()
It compiles regular expression pattern into a regular expression object, which can be used for matching using its match() and search() methods.
..Function findall()
It return all non-overlapping matches of pattern in string, as a list of strings.
For much detailed explanation -->
https://docs.python.org/2/library/re.html
'''
def count_substring(string, sub_string):
c=0
for i in range(0,len(string)):
if string[i:i+len(sub_string)]==sub_string:
c+=1
return c
def count_substring1(string, sub_string):
p=re.compile(sub_string)
a=p.findall(string)
return len(a)
if __name__ == '__main__':
string = input().strip()
sub_string = input().strip()
count = count_substring1(string, sub_string)
#
print(count)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.