Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41671 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2013-03-21 16:04 -0600 |
| Last post | 2013-03-21 16:04 -0600 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: problem with function Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-21 16:04 -0600
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-03-21 16:04 -0600 |
| Subject | Re: problem with function |
| Message-ID | <mailman.3602.1363903475.2939.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
On Mar 21, 2013 1:35 PM, "leonardo selmi" <l.selmi@icloud.com> wrote:
>
> hi all,
>
> i wrote the following code:
>
> def find(word, letter):
> index = 0
> while index < len(word):
> if word[index] == letter:
> return index
> index = index + 1
> return -1
>
More efficient:
def find(word, letter):
return word.find(letter)
Or even:
find = str.find
Cheers,
Ian
Back to top | Article view | comp.lang.python
csiph-web