Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'indices': 0.07; 'function:': 0.09; 'sep': 0.09; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mean,': 0.16; 'values?': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'request,': 0.29; 'basic': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'anything': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'subject:For': 0.75; 'obvious,': 0.91 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=Uzy5blertI+d7t2kY/1PMuvk4jZ55TMUbOgM0ndM7Mk=; b=QPjHaL89Opcqnhkj1iU3GlwClc1tGNH7jweMNDJYZmCUhq+0TD0uRmO/0b73V3WYi/ ZF5jOCMDRlVwaeHN2aPMrV2+LNCbJBuShEuvy7j21sQ9Rh0OayW9E0REufG1dN/JQM0Y Huc2xmm3+JBj09h6y2wGCDxabtlJ/wzElXP/BU7DKmDtaCGZi+DCTPoknIT3YcS+wOUc L4pb2YC2F7wP+tAGl3iCXa/13xGgU27ujSSxgOnIANM2ODVfLTUZgfy4Plc8VIojjlOv xhuM79BEC3Z9esV/omx+g+G2ihmj7EaKMfYqxujoqoKuhElv2zFZ5ZAdeoZAf8RvZbkp 2ccw== MIME-Version: 1.0 In-Reply-To: <10965867-a44f-4146-aea2-fd1a1e8f8e3b@googlegroups.com> References: <10965867-a44f-4146-aea2-fd1a1e8f8e3b@googlegroups.com> Date: Mon, 24 Sep 2012 02:52:43 +1000 Subject: Re: For Counter Variable From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348419165 news.xs4all.nl 6965 [2001:888:2000:d::a6]:52037 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29825 On Mon, Sep 24, 2012 at 2:36 AM, jimbo1qaz wrote: > Am I missing something obvious, or do I have to manually put in a counter in the for loops? That's a very basic request, but I couldn't find anything in the documentation. You mean, if you want the indices as well as the values? Try the enumerate() function: my_list = ["foo", "bar", "quux"] for idx,val in enumerate(my_list): print("Element "+str(idx)+" is: "+val) ChrisA