AttributeError: 'bool' object has no attribute 'count'


Csci319

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 due to the following error. I did some research and tried importing some libraries, but it didn't work. Can someone point me in the right direction? I feel so lost.

 text.count(':') + text.count(';') + \
AttributeError: 'bool' object has no attribute 'count'
Moses Koledoye

You have a wrong line of code in your code:

text = InputFile.readable()

returns booleanno attributescount

should be:

text = InputFile.read()

Related


AttributeError: 'bool' object has no attribute 'count'

Csci319 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(';') +

Python: AttributeError: 'bool' object has no attribute 'all'

SSS I'm adapting a code from someone I'm studying with to solve my problem. Here is his code: if not((paux1 == paux2).all()): pop[int(saidaFO[pos,0]),:] = paux2 pos -= 1 It works, when I print I get the result for paux1: [-2.3668 1.3174].

Django: AttributeError: 'bool' object has no attribute 'expire'

deadlock I'm currently using Andy McCurdy's redis.py module to interact with Redis in Django I use Celery to offload some tasks to the background. Here is one of my tasks: import redis pool = redis.ConnectionPool(host='XX.XXX.XXX.X', port=6379, db=0, password=

Django: AttributeError: 'bool' object has no attribute 'expire'

deadlock I'm currently using Andy McCurdy's redis.py module to interact with Redis in Django I use Celery to offload some tasks to the background. Here is one of my tasks: import redis pool = redis.ConnectionPool(host='XX.XXX.XXX.X', port=6379, db=0, password=

Django: AttributeError: 'Q' object has no attribute 'count'

Joey Coding I try to get the count of all attendees. I created the following for loopand query set. However, I always get the error message AttributeError: 'Q' object has no attribute 'count'. Do you have a solution? # Get count of attendees per ticket and the

Django: AttributeError: 'Q' object has no attribute 'count'

Joey Coding I try to get the count of all attendees. I created the following for loopand query set. However, I always get the error message AttributeError: 'Q' object has no attribute 'count'. Do you have a solution? # Get count of attendees per ticket and the

AttributeError: '' object has no attribute''

gentlemen. Dutch I have a question, I am using python 3 to code. The code is about getting the news of the website onto my canvas. But I keep getting this error which says: AttributeError: 'NewsFeed' object has no attribute 'canvas'. Here is my code: from tkin

AttributeError: object has no attribute

AKHIL MATHEW In my custom Odoo module I have to call a python function when a button is clicked. I followed the exact method from the documentation. But I get error as below.AttributeError: 'book.meeting' object has no attribute 'checkout_function' My code is

AttributeError: 'module' object has no attribute

Stephen Hsu: I have two python modules: py import b def hello(): print "hello" print "a.py" print hello() print b.hi() b.py import a def hi(): print "hi" When I run a.py, I get: AttributeError: 'module' object has no attribute 'hi' What does error me

AttributeError: 'boolean' object has no attribute?

nordic Here is my function: @api.multi def write(self, vals): if vals['Amount'] > 0: vals['Amount_date'] = fields.Datetime.now() record=super(MedicalLab, self).write(vals) self.env['medical.journal'

AttributeError: 'function' object has no attribute

player cow I've been trying to make a game, but this error keeps appearing. I'm a beginner in python so I hope you guys can even take a look at this horrible code. AttributeError: 'function' object has no attribute 'armorEquipped' I'm confused as to what this

AttributeError in python: object has no attribute

Deepesh Patil I started learning machine learning and came across neural networks . I got this error while executing the program. I have tried to check all solutions but no luck. Here is my code: from numpy import exp, array, random, dot class neural_network:

AttributeError: 'namespace' object has no attribute

Sam I'm writing a program that uses urllib2 to download CSV data from an http site . The program works fine when run in Python, but I've also tried using argparse to enter the URL from the command line. I get the following error when running it: File "urlcsv.p

AttributeError: Object has no attribute 'title'

epx I am learning to program the collective intelligence book. Below is my code: import feedparser import re # Returns title and dictionary of word counts for an RSS feed def getwordcounts(url): # Parse the feed d = feedparser.parse(url) wc={}

AttributeError: type object has no attribute

Jim Beam This is a valid multilevel inheritance program. When I run it, it says "AttributeError: object of type 'starts' has no attribute 'math'". I checked the class associations and they inherit. I'm a beginner so it will help me a lot going forward. class s

AttributeError: Object has no attribute 'split'

username When I try to split I get an error l =[u'this is friday', u'holiday begin'] split_l =l.split() print(split_l) The error is: Traceback (most recent call last): File "C:\Users\spotify_track2.py", line 19, in <module> split_l =l.split() AttributeE

AttributeError: 'boolean' object has no attribute

Adam Dalton I'm working on a Django project and essentially I've written a model that stores user details. They have completed this profile after registration and I have a boolean in the user model that indicates if they have completed this custom profile so I

AttributeError - object has no attribute 'create'

Andrew O I'm trying to save a passthrough model with the following properties via Django-rest-framework When sending a POST (I'm trying to create a new instance), I get the following error: AttributeError for /api/organisation/provider/ 'EnabledExternalProvide

AttributeError: 'dict' object has no attribute '____'

cast a spell I've been messing around with this code for hours and it still gives me errors. I would like to do an "auto-marking" for the test where you introduce good and bad answers and then calculate the final score. Code: class puntuacion: def __init__

AttributeError: 'namespace' object has no attribute

Sam I'm writing a program that uses urllib2 to download CSV data from an http site . The program works fine when run in Python, but I'm also trying to use argparse to enter the URL from the command line. I get the following error when running it: File "urlcsv.

AttributeError: 'boolean' object has no attribute?

nordic Here is my function: @api.multi def write(self, vals): if vals['Amount'] > 0: vals['Amount_date'] = fields.Datetime.now() record=super(MedicalLab, self).write(vals) self.env['medical.journal'

AttributeError: 'boolean' object has no attribute?

nordic Here is my function: @api.multi def write(self, vals): if vals['Amount'] > 0: vals['Amount_date'] = fields.Datetime.now() record=super(MedicalLab, self).write(vals) self.env['medical.journal'

AttributeError: 'function' object has no attribute

player cow I've been trying to make a game, but this error keeps appearing. I'm a beginner in python so I hope you guys can even take a look at this horrible code. AttributeError: 'function' object has no attribute 'armorEquipped' I'm confused as to what this

AttributeError: 'function' object has no attribute

player cow I've been trying to make a game, but this error keeps appearing. I'm a beginner in python so I hope you guys can even take a look at this horrible code. AttributeError: 'function' object has no attribute 'armorEquipped' I'm confused as to what this

AttributeError in python: object has no attribute

Deepesh Patil I started learning machine learning and came across neural networks . I got this error while executing the program. I have tried to check all solutions but no luck. Here is my code: from numpy import exp, array, random, dot class neural_network: