We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Enter your code here. Read input from STDIN. Print output to STDOUTimportresentences=[]N=int(input())for_inrange(N):sentences.append(str(input()))T=int(input())for_inrange(T):total=0word=str(input())pattern=r'(?:(?<=\b)|(?<=\W))'+word+r'(?=\b|\W)'forsentenceinsentences:wfound=re.findall(pattern,sentence)total+=len(wfound)print(total)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Find a Word
You are viewing a single comment's thread. Return to all comments →
Python 3