Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75922 > unrolled thread

Re: how to get the ordinal number in list

Started byLarry Martell <larry.martell@gmail.com>
First post2014-08-08 22:25 -0400
Last post2014-08-08 22:25 -0400
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.


Contents

  Re: how to get the ordinal number in list Larry Martell <larry.martell@gmail.com> - 2014-08-08 22:25 -0400

#75922 — Re: how to get the ordinal number in list

FromLarry Martell <larry.martell@gmail.com>
Date2014-08-08 22:25 -0400
SubjectRe: how to get the ordinal number in list
Message-ID<mailman.12777.1407551141.18130.python-list@python.org>
On Sat, Aug 9, 2014 at 1:22 PM, luofeiyu <elearn2014@gmail.com> wrote:
>>>> x=["x1","x3","x7","x5"]
>>>> y="x3"
>
>  how can i get the ordinal number by some codes?
>
> for id ,value in enumerate(x):
>     if y==value : print(id)
>
> Is more simple way to do that?

print x.index(y)

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web