Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41665
| From | "Alex" <foo@email.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: problem with function |
| Date | 2013-03-21 20:11 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <kifpgq$9v1$1@dont-email.me> (permalink) |
| References | <mailman.3594.1363894319.2939.python-list@python.org> |
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?
>
What does your call to find look like? I called it with:
find("word", 'd')
and it returned 3, as expected.
If I call find with
find(word, 'd')
I get an error, as expected, since I have not assigned a string to the
name word.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
problem with function leonardo selmi <l.selmi@icloud.com> - 2013-03-21 19:31 +0100 Re: problem with function "Alex" <foo@email.invalid> - 2013-03-21 20:11 +0000
csiph-web