read_plaintext() wird zu read_text() und Text wird lower()

breakmono2
Daniel Tschertkow 5 years ago
parent b911cc2568
commit def2413f91

@ -4,7 +4,7 @@ module to encapsulate common functions for exercise01.
import string
def read_plaintext(file_path):
def read_text(file_path):
"""
funciton to read plaintext from a file into a string variable.
Skips non-alphabetic characters (including whitespace) and converts the rest to lower case.
@ -12,7 +12,7 @@ def read_plaintext(file_path):
txt = ""
with open(file_path, "r") as _file:
for line in _file:
for char in line:
for char in line.lower():
if char in string.ascii_letters:
txt += char
return txt

Loading…
Cancel
Save