0

I am new to Python and I am writing this code below.

fileName = input("Enter the file name: ")
InputFile = open(fileName, 'r')
text=InputFile.readable()

sentences = text.count('.') + text.count('?') + \
            text.count(':') + text.count(';') + \
            text.count('!')

I can't get past the count function because of this error below. I have done some research and tried importing some libraries but that didn't work. Can someone guide me in the right direction? I feel so lost.

 text.count(':') + text.count(';') + \
AttributeError: 'bool' object has no attribute 'count'
1
  • 4
    What do you think text=InputFile.readable() is doing? Commented Jun 14, 2016 at 14:17

1 Answer 1

5

There is a buggy line in your code:

text = InputFile.readable()

Which returns a boolean that has no attribute count

Should have been:

text = InputFile.read()
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. Can I ask you one more question? In this line of code what is the "\" symbol if "/" is division? index = 206.835 - 1.015 * (words / sentences) - \ 84.6 * (syllables / words)
yes. Is this an operator that allows you put the rest of the code on another line?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.