Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38214
| X-Received | by 10.224.110.68 with SMTP id m4mr13742490qap.2.1360089797492; Tue, 05 Feb 2013 10:43:17 -0800 (PST) |
|---|---|
| X-Received | by 10.49.24.13 with SMTP id q13mr2261566qef.33.1360089797472; Tue, 05 Feb 2013 10:43:17 -0800 (PST) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!p13no15007477qai.0!news-out.google.com!k2ni8436qap.0!nntp.google.com!p13no15007473qai.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Tue, 5 Feb 2013 10:43:17 -0800 (PST) |
| In-Reply-To | <2b0eb097-e575-4d6d-a509-f4c6bd58c934@googlegroups.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=192.138.213.253; posting-account=PfzcdwoAAACWtPiyaNT0F0B61jJ58_vo |
| NNTP-Posting-Host | 192.138.213.253 |
| References | <2b0eb097-e575-4d6d-a509-f4c6bd58c934@googlegroups.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <b6d5a637-e2f9-40ad-9c71-1b7fe0015d17@googlegroups.com> (permalink) |
| Subject | Re: Issue with my code |
| From | maiden129 <sengokubasarafever@gmail.com> |
| Injection-Date | Tue, 05 Feb 2013 18:43:17 +0000 |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | quoted-printable |
| Xref | csiph.com comp.lang.python:38214 |
Show key headers only | View raw
Also I’m using Python 3.2.3.
On Tuesday, February 5, 2013 1:38:55 PM UTC-5, 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'
>
>
>
> I wanted to show like this:
>
>
>
> Example:
>
>
>
> Enter a string: 3233456
>
>
>
> 3 occurs 3
>
> 2 occurs 1
>
> 4 occurs 1
>
> 5 occurs 1
>
> 6 occurs 1
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Issue with my code maiden129 <sengokubasarafever@gmail.com> - 2013-02-05 10:38 -0800
Re: Issue with my code maiden129 <sengokubasarafever@gmail.com> - 2013-02-05 10:43 -0800
Re: Issue with my code marduk <marduk@python.net> - 2013-02-05 13:56 -0500
Re: Issue with my code maiden129 <sengokubasarafever@gmail.com> - 2013-02-05 11:20 -0800
Re: Issue with my code Dave Angel <davea@davea.name> - 2013-02-05 14:43 -0500
Re: Issue with my code maiden129 <sengokubasarafever@gmail.com> - 2013-02-05 12:19 -0800
Re: Issue with my code maiden129 <sengokubasarafever@gmail.com> - 2013-02-05 12:19 -0800
Re: Issue with my code darnold <darnold992000@yahoo.com> - 2013-02-05 13:37 -0800
Re: Issue with my code marduk <marduk@python.net> - 2013-02-05 17:05 -0500
Re: Issue with my code darnold <darnold992000@yahoo.com> - 2013-02-05 14:25 -0800
Re: Issue with my code maiden129 <sengokubasarafever@gmail.com> - 2013-02-05 11:20 -0800
Re: Issue with my code MRAB <python@mrabarnett.plus.com> - 2013-02-05 19:06 +0000
Re: Issue with my code Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-05 17:20 -0500
Re: Issue with my code Terry Reedy <tjreedy@udel.edu> - 2013-02-05 19:06 -0500
Re: Issue with my code rusi <rustompmody@gmail.com> - 2013-02-05 22:29 -0800
Re: Issue with my code rusi <rustompmody@gmail.com> - 2013-02-05 22:32 -0800
csiph-web