On Feb 21, 2015 8:49 AM, "Tim Johnson" <pavemen...@gmail.com> 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:* > * counter = counter + 1* > *print counter*
Hmmm... I don't understand what the intent of the last line of the program is. Can you explain what you're trying to do there? Do you intend to do this print after the for loop? If so, it should still be scoped to the function though. At the moment, it is a statement that's entirely separate from the function definition. Good luck! _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor