diff --git a/SentenceLength.py b/SentenceLength.py index 4ee13bc..5d5b3db 100644 --- a/SentenceLength.py +++ b/SentenceLength.py @@ -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))