problem with function
Dave Angel
davea at davea.name
Thu Mar 21 15:48:23 EDT 2013
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
More information about the Python-list
mailing list