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


Groups > comp.lang.python > #41662 > unrolled thread

Re: problem with function

Started byDave Angel <davea@davea.name>
First post2013-03-21 15:48 -0400
Last post2013-03-21 15:48 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: problem with function Dave Angel <davea@davea.name> - 2013-03-21 15:48 -0400

#41662 — Re: problem with function

FromDave Angel <davea@davea.name>
Date2013-03-21 15:48 -0400
SubjectRe: problem with function
Message-ID<mailman.3596.1363895324.2939.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web