Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83243
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <i@introo.me> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.030 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; 'else:': 0.03; 'counting': 0.09; 'def': 0.12; 'jan': 0.12; 'assume': 0.14; 'received:143': 0.16; 'skip:` 30': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'subject:problem': 0.24; 'header:In-Reply-To:1': 0.27; 'code': 0.31; 'subject:with': 0.35; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'letters': 0.60; 'skip:z 20': 0.60; 'content-disposition:inline': 0.62; 'more': 0.64; 'url:me': 0.69 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=0+puPbg02GqP+R2jZtzADKD6XyJAlFDeMTxToq674Bo=; b=dWusZFMw9dYNtlErf0EGdXWZYxNd5KU4Fd4B2JjL5QggquIwnD1HQY28k8ZdIvc4Qx 1KSafmtD9/sSpudjM/dYbxMiXb53+wTPjrFAWMr8wvNZE4v6FRzbozuB3wDqAbBVKP1s VD86CsSxXZsQgHLZNpqmQnaMzJwYHc02NmAB7o/F93+c7qF+HgYC0Bf1+UQ95CwBhQ7/ CXKAQzaa7V+GXM0YqkRWQZ3lH9rvLi6LizFavfl7WFSvEUG+alctY+4SWkZFdqAItrTz bWsFF2uXbwUyuEqcY1KqVTtOoQvEmE19x2t77RYDZS0ou0AwIS4Qh0HLtp/PqA5EYtlK p9DA== |
| X-Gm-Message-State | ALoCoQmTcaz/l1z+Zw+UDUxHH0C5v9oA8JAUbeYAwx4zrXz5DP4WibMCVXsquLXooSAOQ0BhmfhX |
| X-Received | by 10.66.249.226 with SMTP id yx2mr147294553pac.112.1420468686390; Mon, 05 Jan 2015 06:38:06 -0800 (PST) |
| Date | Mon, 5 Jan 2015 22:38:02 +0800 |
| From | Shiyao Ma <i@introo.me> |
| To | python-list@python.org |
| Subject | Re: problem with for and if |
| References | <a71e126d-4b27-42a3-8103-3381b62794d2@googlegroups.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Disposition | inline |
| In-Reply-To | <a71e126d-4b27-42a3-8103-3381b62794d2@googlegroups.com> |
| User-Agent | All mail clients suck. This one just sucks way more. |
| X-Info | Find me @introom on Freenode. Have beers! :) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17396.1420468696.18130.python-list@python.org> (permalink) |
| Lines | 33 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1420468696 news.xs4all.nl 2953 [2001:888:2000:d::a6]:47039 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:83243 |
Show key headers only | View raw
On Jan 05 at 06:27 -0800, Dariusz Mysior wrote:
> I want search count of szukana in zmienna but code below counting all 12 letters from "traktorzysta" word
>
> szukana="t"
> zmienna="traktorzysta"
>
>
> def gen():
> count=int(0)
> for a in zmienna:
> if szukana in zmienna:
> count+=1
> else:
> continue
> return count
def gen():
count = 0
for a in zmienna:
# we assume szukana is a single letter
if szukana == a:
count+=1
else:
continue
return count
More preferably, you should repetitively use "str.find"
Or just use `max(0,len(zmienna.split(szukana))-1)`
--
Shiyao Ma
http://introo.me
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
problem with for and if Dariusz Mysior <mysior.darek@gmail.com> - 2015-01-05 06:27 -0800 Re: problem with for and if Shiyao Ma <i@introo.me> - 2015-01-05 22:38 +0800 Re: problem with for and if YBM <ybmess@nooos.fr.invalid> - 2015-01-05 15:39 +0100 Re: problem with for and if Chris Warrick <kwpolska@gmail.com> - 2015-01-05 15:41 +0100 Re: problem with for and if Dariusz Mysior <mysior.darek@gmail.com> - 2015-01-05 06:47 -0800 Re: problem with for and if MRAB <python@mrabarnett.plus.com> - 2015-01-05 14:48 +0000 Re: problem with for and if Shiyao Ma <i@introo.me> - 2015-01-05 22:57 +0800 Re: problem with for and if Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-06 12:12 +1100
csiph-web