import re def openFile(fileName,piesArray1 = [' ', 'P', 'p', '('], piesArray2 = ['i', 'e', 's'], piesArray3 = ['\t', '\n', '.', ',', ';', '!', '?', ')']): with open(fileName, "r", encoding="utf-8") as file: file_contents = file.read() for row in file: piesArrayCounter = 0 repCounter = 0 counter = 0 checkWord = '' for character in row: if character == ' ': checkWord+=character if counter == 0 and checkWord == ' ': if (character == 'P' or character == 'p'): counter +=1 print('---------------------SHAKESPEARE.EXP--------------------------------------') openFile('shakespeare.exp') print('----------------------SHAKESPEARE.EXP-----------------------------------') openFile('shakespeare.in') print('------------------------SIMPLE.IN------------------------------------') openFile('simple.in') print('-----------------------SIMPLE.EXP--------------------------------------') openFile('simple.exp')