Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41661

Re: problem with function

References <870147F2-AF34-456A-BDF3-12C0A2F67A69@icloud.com>
Date 2013-03-22 06:40 +1100
Subject Re: problem with function
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3595.1363894837.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Mar 22, 2013 at 5:31 AM, leonardo selmi <l.selmi@icloud.com> 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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: problem with function Chris Angelico <rosuav@gmail.com> - 2013-03-22 06:40 +1100

csiph-web