Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41665
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | "Alex" <foo@email.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: problem with function |
| Date | Thu, 21 Mar 2013 20:11:06 +0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 32 |
| Message-ID | <kifpgq$9v1$1@dont-email.me> (permalink) |
| References | <mailman.3594.1363894319.2939.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 21 Mar 2013 20:11:06 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="72dc6a9c0740cf94e68329f099dbd9be"; logging-data="10209"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WCf6qlRqpdRIgJ4SRea0VYvxvo2Y+IYI=" |
| User-Agent | XanaNews/1.19.1.320 |
| Cancel-Lock | sha1:2qO3/CywmQv3sU33/BH8HQFBBbY= |
| Xref | csiph.com comp.lang.python:41665 |
Show key headers only | View raw
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