Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

• In Homework-08, we will continue working with the file Gettysburg.txt. • Note

ID: 3590978 • Letter: #

Question

• In Homework-08, we will continue working with the file Gettysburg.txt. • Note that the text file contains one sentence for every line in the text file. • Write a program that reads the file's contents and determines the total number of words in the Gettysburg Address. • If you look closely at the Gettysburg Address, you will notice that Lincoln used an interesting piece of punctuation many times in his address. It looks like this: “ -- ” (two hyphens together with a space on either side). these do not count as words. note: Don’t simply count the number of “ -- ” that Lincoln used in the address and subtract that from your total of the number of words, as we want this program to give the correct number of words with any text document. Write this in PYTHON

Explanation / Answer

file = open("Gettysburg.txt","r")
count = 0
count1 = 0
for line in file:
    if " -- " in line:
      list = line.split(' -- ')
      count1 = len(list)-1
      list = line.split(' ')
      count = count + len(list) - count1  
    else:
      list = line.split(' ')
      count = count + len(list)

print("Number of words :",count)   
print("Number of Lincoln punctuation :",count1)