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.


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to