Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'error:': 0.05; 'function,': 0.07; 'python': 0.09; 'defined.': 0.09; 'def': 0.10; 'index': 0.13; 'letter:': 0.16; 'sequence,': 0.16; 'wrote:': 0.17; 'code,': 0.18; 'all,': 0.21; 'subject:problem': 0.22; 'somewhere': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'wrote': 0.26; 'lines': 0.28; 'run': 0.28; 'error': 0.30; 'running': 0.32; 'print': 0.32; 'message.': 0.33; 'to:addr:python- list': 0.33; 'code:': 0.33; 'version': 0.34; 'pm,': 0.35; 'add': 0.36; 'subject:with': 0.36; 'subject:: ': 0.38; 'nothing': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'solve': 0.62; 'show': 0.63; 'results': 0.65; 'received:74.208': 0.71; 'window,': 0.84 Date: Thu, 21 Mar 2013 15:48:23 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: python-list@python.org Subject: Re: problem with function References: <870147F2-AF34-456A-BDF3-12C0A2F67A69@icloud.com> In-Reply-To: <870147F2-AF34-456A-BDF3-12C0A2F67A69@icloud.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:zHlA+jhRybV7jwZZHFlTIS3/GKoYXXGKYFSoI+WsPQe TGQfCAFFQ/I4I79IExm6/5F/JojKOFEoS0r/ewttiaVrZp01Q4 ZMxQ8xyLkOJLmnirYlkiElE/CteQmXh4ChDbl7+lcsgiz/gI9f XKNj+DUeWeEcokjsBwrlWZ5vmPhTiEeQIzV2KVS8rNT21YBvb0 GYUGl5ndZauxaQx72BH7NMSazsRSBgny7RHEqqfcRJaH2nEz69 1cSxhzlgLTwWId/hE/3zpWElzw3tkUP/Ofy1jXx5ZqCPRaeHbS TkEX4uAaxMtm49b2U0RqIdHhuS60GF1hlJXVDANlSNCr1EQLQ= = 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363895324 news.xs4all.nl 6934 [2001:888:2000:d::a6]:37056 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41662 On 03/21/2013 02:31 PM, 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? > If I run it, I get nothing at all, since there's no call to find()). And when I add lines that print the results of calling the function, I get reasonable results. How about if you do the following: 1) tell us Python version and OS. 2) show us the whole code, copy/pasted into your message 3) show us the whole error message (traceback), copy/pasted into your message And if you're running it from somewhere other than a terminal window, tell us how you're running it. Or better, run it from a terminal, and show us the whole sequence, by copy/pasting from the terminal to the message. -- DaveA