Created
November 24, 2017 23:04
-
-
Save glauesppen/32eff090b8353a7fdf93b0679643b2bc to your computer and use it in GitHub Desktop.
Function search in a text file for a keyword and return the sentences it belongs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search_text(text, keyword): | |
with open(text,'r') as t: | |
for period in t: | |
for sentence in period.split('.'): | |
if keyword in sentence: | |
print sentence |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment