python type error: a is undefined
===

Python newbie here. I am writing a program to count how many times a substring is a string, but keep receiving the error message: TypeError: a is undefined. I have looked at /googled similar threads but the code is usually convoluted and hard to follow.


Here is my code: 

    def stringcount(char, word):
    for eachChar in word:
        if char==eachChar:
            count=count+1
            return count
        print count

    stringcount('a', 'apple')

Thanks a lot!

