Path: csiph.com!usenet.pasdenom.info!goblin3!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'error:': 0.05; '22,': 0.09; 'defined.': 0.09; 'def': 0.10; 'index': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'letter:': 0.16; 'library.)': 0.16; 'trace.': 0.16; 'wrote:': 0.17; 'exists': 0.17; 'code,': 0.18; 'all,': 0.21; 'error.': 0.21; 'subject:problem': 0.22; 'header:In-Reply-To:1': 0.25; 'wrote': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; 'fine': 0.28; 'run': 0.28; 'post': 0.28; 'fri,': 0.30; 'function': 0.30; 'error': 0.30; 'code': 0.31; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'subject:with': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'end': 0.40; 'your': 0.60; "you'll": 0.62; 'solve': 0.62; '2013': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=gT8jdmNYAfKhS8Jk4ZmpyCjUYPThxfmZcimDgeN/t/U=; b=f2Wx6SJFK0HvfBRbtbRdc/2/Sem78GfV7PfywDzI5vzszD7VG3bA/7MaQZHof6IF1W vxiqtXIOJrKW/R2sFc0zLz2j1zLNwhi8vYHt9PM9RH2mAlukNzQNbSppl+DdjHs/0moQ lV97gnMAXSonMW0oYtBs9gbUaSRmczhNIEJkbHjUJ+0rkEfpdZHyWciS3YS0QSAEe+Dn QWKLzGiPR3Dex76t5/+z2txYbhWfUzgitW/pdB8yK00NbRpJuGJ4RG0cYTPuNFVlvR4/ 2kaYH9+ZJ04GpLxoM73+FiDB7uY8/K8vJblOU536cV6V59KW2BoOs+cCQy5cuRDRsLzG IfmA== MIME-Version: 1.0 X-Received: by 10.52.29.209 with SMTP id m17mr12901748vdh.111.1363894835147; Thu, 21 Mar 2013 12:40:35 -0700 (PDT) In-Reply-To: <870147F2-AF34-456A-BDF3-12C0A2F67A69@icloud.com> References: <870147F2-AF34-456A-BDF3-12C0A2F67A69@icloud.com> Date: Fri, 22 Mar 2013 06:40:35 +1100 Subject: Re: problem with function 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363894837 news.xs4all.nl 6905 [2001:888:2000:d::a6]:59973 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41661 On Fri, Mar 22, 2013 at 5:31 AM, leonardo selmi wrote: > hi all, > > i wrote the following code: > > def find(word, letter): > index = 0 > while index < len(word): > if word[index] == letter: > return index > index = index + 1 > return -1 > > if i run the program i get this error: name 'word' is not defined. how can i solve it? You'll need to post the whole code of your program. That function works fine for me. (Though it's somewhat unPythonic code, and in any case already exists in the standard library.) Tip: Look at the full traceback from the error. Chances are you'll find the cause of the error on one of the lines near the end of the trace. ChrisA