Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.04; 'attribute': 0.05; 'error:': 0.05; 'subject:code': 0.07; 'modifies': 0.09; 'occurrences': 0.09; 'received:internal': 0.09; 'checks:': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:mail.srv.osa': 0.16; 'received:messagingengine.com': 0.16; 'received:nyi.mail.srv.osa': 0.16; 'received:osa': 0.16; 'received:srv.osa': 0.16; 'string': 0.17; 'wrote:': 0.17; 'string,': 0.17; 'subject:Issue': 0.17; '>>>': 0.18; 'code,': 0.18; 'feb': 0.19; 'trying': 0.21; 'pass': 0.25; 'header:In-Reply- To:1': 0.25; 'probably': 0.29; "i'm": 0.29; 'to:addr:python-list': 0.33; 'code:': 0.33; 'hi,': 0.33; 'list': 0.35; 'pm,': 0.35; 'there': 0.35; 'but': 0.36; 'subject:with': 0.36; 'keeps': 0.37; 'does': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.62; 'here': 0.65; 'counts': 0.81 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=0a9TyS8fKl1i4lHiVvbxy4pLo/I=; b=RM6 K5cbg1OfWtEw/SMRraXNIuti/zNst2MvRkuc85On6m1Q3P6ElqGy1mujMsJgCnCf JEzlcvBF8lKLgVFbVp4kcy+epi3InYVln9pgKqvEndN/24IFZXgC7Jm0t/aAwdx1 YAa2L9bHEkyhqYov1kJeyFLEpAlkwgvTgfczaRpw= X-Sasl-Enc: 3WfNFJXgiTooRwMzSUjmS+h2liD5iSpFvpP8BmgElCvj 1360090615 From: marduk To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-1ec1891e In-Reply-To: <2b0eb097-e575-4d6d-a509-f4c6bd58c934@googlegroups.com> References: <2b0eb097-e575-4d6d-a509-f4c6bd58c934@googlegroups.com> Subject: Re: Issue with my code Date: Tue, 05 Feb 2013 13:56:55 -0500 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360090617 news.xs4all.nl 6874 [2001:888:2000:d::a6]:53035 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38216 On Tue, Feb 5, 2013, at 01:38 PM, maiden129 wrote: > Hi, > > I'm trying to create this program that counts the occurrences of each > digit in a string which the user have to enter. > > Here is my code: > > s=input("Enter a string, eg(4856w23874): ") > s=list(s) > > checkS=['0','1','2','3','4','5','6','7','8','9'] > > for i in s: > if i in checkS: > t=s.count(i) > if t>1: > for k in range(1,t): > s=s.remove(i) > print(i, "occurs", t,"times.") > > elif t==1: > print(i,"occurs 1 time.") > else: pass > > but it keeps showing this error: > > t=s.count(i) > AttributeError: 'NoneType' object has no attribute 'count' s=s.remove(i) does not return a new list but modifies the list in place. So you probably just want >>> s.remove(i) Also, there are various inefficiencies in your code, but that is the main issue with the AttributeError.