Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.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.048 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'that?': 0.05; 'subject:number': 0.09; 'ordinal': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'aug': 0.22; 'to:name:python-list@python.org': 0.22; 'print': 0.22; 'header:In-Reply-To:1': 0.27; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; 'subject:the': 0.34; 'received:google.com': 0.35; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'simple': 0.61; 'more': 0.64; 'subject:get': 0.81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=I/Avh09lhbma+kNVKqfx5YIsSLm2WW4UVkc+QXeOs80=; b=W8bQZVET6dU+a8xp6tPltt/1HhTr253SqMbHA9H3zBbhmrEC3sQL1OW6KfMzGlaSFT TcGdX6I0SG/vY5mLEtcU6NEcTCG4aIZbNjae5G50/sCImrdHoqUokpFYBJbOQQWSdFcU 3/R/XV9FIxz91undQtrrJ5uoBwqfsuFe5HfK9cr2kqYRlf/OWyfowY/Yc9jW2fdyGOWA 6ODUM+2Au6F6B78jksOK6dt2pMOTPeeI9kI49TDy3BhGL8XCPjsZbzYtQlNataiNwMte eePbkNgstTe2UTlqHK3NwWvWK6Z20qcfOgRW5VLEoZwPDAyw7SQp/SRHm3qTI69+I6Qv owKg== MIME-Version: 1.0 X-Received: by 10.180.10.138 with SMTP id i10mr7804754wib.81.1407551140065; Fri, 08 Aug 2014 19:25:40 -0700 (PDT) In-Reply-To: <53E658CD.5020904@gmail.com> References: <53E658CD.5020904@gmail.com> Date: Fri, 8 Aug 2014 22:25:40 -0400 Subject: Re: how to get the ordinal number in list From: Larry Martell To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407551141 news.xs4all.nl 2921 [2001:888:2000:d::a6]:48278 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75922 On Sat, Aug 9, 2014 at 1:22 PM, luofeiyu 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)