Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'yet.': 0.04; 'subject:Python': 0.06; '21,': 0.07; 'sys': 0.07; 'steve': 0.09; '34,': 0.09; '[1,': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; '~ethan~': 0.09; 'random': 0.14; '55,': 0.16; 'indexerror:': 0.16; 'steve:': 0.16; 'index': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'math': 0.24; 'second': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; '13,': 0.31; 'sep': 0.31; 'file': 0.32; '(most': 0.33; 'third': 0.33; 'no,': 0.35; 'charset:us-ascii': 0.36; 'list': 0.37; 'list.': 0.37; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'range': 0.61; 'received:173': 0.61; 'first': 0.61; 'total': 0.65 Date: Wed, 03 Sep 2014 11:55:13 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python is going to be hard References: <9eoe0apt76pbd5slks20bjaq24m5mrqe3f@4ax.com> In-Reply-To: <9eoe0apt76pbd5slks20bjaq24m5mrqe3f@4ax.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409770515 news.xs4all.nl 2834 [2001:888:2000:d::a6]:57230 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77498 On 09/03/2014 11:49 AM, Seymore4Head wrote: > On Wed, 03 Sep 2014 14:10:42 -0400, Seymore4Head > wrote: > >> import math >> import random >> import sys >> b=[] >> steve = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] >> for x in steve: >> print (steve[x]) >> >> Traceback (most recent call last): >> File "C:\Functions\blank.py", line 7, in >> print (steve[x]) >> IndexError: list index out of range > > Ok, I understand now that x is actually the first item in the list. > What I want is a loop that goes from 1 to the total number of items in > the list steve. No, you don't understand yet. The /first/ time through the loop 'x' is the first item in the list. The /second/ time through the loop 'x' is the second item in the list. The /third/ time through the loop 'x' is the third item in the list. . . . Keep persisting! -- ~Ethan~