Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions SentenceLength.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@ def findAverageSentence(filePath, delimiters, minLength):

def main():
userFile = input("Enter the file path to the .txt file you wish to analyze.\n")
isFile = os.path.isfile(userFile)
while isFile != True:
print("Enter a valid file")
userFile = input("Enter the file path to the .txt file you wish to analyze.\n")
isFile = os.path.isfile(userFile)



userDelimeters = input("Enter the characters (punctuation) that you want to be sentence delimiters separated by spaces.\n")
userDelimeters = userDelimeters.split(" ")
minLength = input("Enter the minimum length of a word (must be a positive integer).\n")

minLenPro = ""

for i in range(len(minLength)):
# print("1234567890".contains(minLength[i]))
if (minLength[i] in "1234567890") == False:
minLenPro = minLenPro + ""
else:
minLenPro = minLenPro + minLength[i]

print(minLenPro)


print("The average sentence length is", findAverageSentence(userFile, userDelimeters, minLength))

Expand Down