[Tutor] NameError: name 'counter' is not defined, was Re: Tutor Digest, Vol 132, Issue 51

2015-02-21 Thread Peter Otten
Tim Johnson wrote: > Hi Guys, Hi Tim! > Very simple question, I imagine. > > this code throws of off a "counter not defined error". Instead of retyping the error message it is better to cut and paste the traceback, e. g. Traceback (most recent call last): File "tmp.py", line 6, in pri

Re: [Tutor] Counter not defined error

2015-02-21 Thread Mark Lawrence
On 21/02/2015 16:48, Tim Johnson wrote: I've changed the subject line to reflect your question. Did you have to reply to the digest and include the lot of it, why couldn't you simply start a new thread? Hi Guys, Very simple question, I imagine. this code throws of off a "counter not define

Re: [Tutor] Tutor Digest, Vol 132, Issue 51

2015-02-21 Thread Alan Gauld
On 21/02/15 16:48, Tim Johnson wrote: Hi Guys, Hi, please don't send the entire digest, some folks pay by the byte. Ideally send a new mail to tutor@python.org instead of replying to an existing digest. Also change the subject to something meaningful so folks an find it in the archives. *d

Re: [Tutor] Tutor Digest, Vol 132, Issue 51

2015-02-21 Thread Danny Yoo
On Feb 21, 2015 8:49 AM, "Tim Johnson" wrote: > > Hi Guys, > Very simple question, I imagine. > > this code throws of off a "counter not defined error". > Can you help? > > *def word_counter(word, string):* > *counter = 0* > *for item in string:* > *if item == word:* > *

Re: [Tutor] Tutor Digest, Vol 132, Issue 51

2015-02-21 Thread Tim Johnson
Hi Guys, Very simple question, I imagine. this code throws of off a "counter not defined error". Can you help? *def word_counter(word, string):* *counter = 0* *for item in string:* *if item == word:* *counter = counter + 1* *print counter* Thanks, Tim -- Tim Johnso