Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: why for loop print only once after add if statement Date: Sat, 28 May 2016 12:59:14 -0400 Organization: IISS Elusive Unicorn Lines: 65 Message-ID: References: <4743c1df-de66-44e1-9d27-b62582d757ac@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de pJVgrQ1uG1EoqHwDw34GAAS461vgPwYgyJBU8LZzq20A== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'value,': 0.03; 'testing,': 0.05; '(0,': 0.09; '(1,': 0.09; 'item,': 0.09; 'message- id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:why': 0.09; 'index': 0.13; 'value.': 0.15; "'a')": 0.16; "'i')": 0.16; "'s')": 0.16; '(2,': 0.16; '(3,': 0.16; '(8,': 0.16; '(9,': 0.16; '2016': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:after': 0.16; 'url:home': 0.18; '>>>': 0.20; 'sat,': 0.23; 'second': 0.24; 'header:X-Complaints- To:1': 0.26; 'idea': 0.28; 'values': 0.28; 'actual': 0.28; 'print': 0.30; "can't": 0.32; '-0700': 0.33; 'item': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'stuff': 0.38; 'means': 0.39; 'to:addr:python.org': 0.40; 'term': 0.60; 'email addr:gmail.com': 0.62; 'further': 0.62; 'contains.': 0.84; 'dennis': 0.91; 'subject:add': 0.91; 'writing,': 0.91; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: adsl-108-73-116-140.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <4743c1df-de66-44e1-9d27-b62582d757ac@googlegroups.com> Xref: csiph.com comp.lang.python:109216 On Sat, 28 May 2016 03:19:10 -0700 (PDT), jobmattcon@gmail.com declaimed the following: >for item, i in enumerate(aa) > print item > >this writing, it can print all values > >for item, i in enumerate(aa) > if item == findit: > print item > >this only print the first value, means it only print once then not print again, > >where is wrong? First thought... for i, item in enumerate(aa): The first term is the (zero-base) index and the second is the actual item value. No idea what "findit" is, so can't do any further testing, nor what "aa" contains. >>> aa = "alcoholics anonymous" >>> for stuff in enumerate(aa): ... print stuff ... (0, 'a') (1, 'l') (2, 'c') (3, 'o') (4, 'h') (5, 'o') (6, 'l') (7, 'i') (8, 'c') (9, 's') (10, ' ') (11, 'a') (12, 'n') (13, 'o') (14, 'n') (15, 'y') (16, 'm') (17, 'o') (18, 'u') (19, 's') >>> >>> for i, v in enumerate(aa): ... if v == "o": ... print i ... 3 5 13 17 >>> -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/