Question: I have to alter this code in some way. I was thinking of adding a line that counts the total number of characters. Code below

I have to alter this code in some way. I was thinking of adding a line that counts the total number of characters.

Code below

file=input("Enterfilename:")

inputFile=open(file,'r')

text=inputFile.read()

sentenceCount=text.count('.')+text.count('?')+text.count(';')+text.count('!')

wordCount=len(text.split())

syllables=0

vowels="aeiouAEIOU"

forwordintext.split():

forvowelinvowels:

syllables+=word.count(vowel)

forendingin['es','ed','e']:

ifword.endswith(ending):

syllables-=1

ifword.endswith('le'):

syllables+=1

index=206.835-1.015*(wordCount/sentenceCount)-84.6*(syllables/wordCount)

level=round(.39*(wordCount/sentenceCount)+11.8*(syllables/wordCount)-15.59)

print("TheFleschIndexis",index)

print("TheGradeLevelEquivalentis",level)

print(sentenceCount,"sentences")

print(wordCount,"words")

print(syllables,"syllables")

I added the followings lines but the result is showing as 0 number of characters

data=inputFile.read()

charCount=len(data)

print(charCount,"numberofcharacters")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!