Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pyton count senteses in a text file

fname = "gettysburg.txt"

num_lines = 0
num_words = 0
num_chars = 0

with open(fname, 'r') as f:
    for line in f:
        words = line.split()

        num_lines += line.count(".")
        num_words += len(words)
        num_chars += len(line.replace(' ', ''))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pyton #count #senteses #text #file
ADD COMMENT
Topic
Name
6+3 =