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'
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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.