"""File: count_occur.py Purpose: Count the number of times a letter occurs in a word Run: python count_occur.py Input: A word and a letter Output: The number of times letter occurs in word """ def how_many(let, s): """Count the number of times let occurs in s""" count = 0 for l in s: if l == let: count = count+1 return count #---------------------------------------------------------------------- word = raw_input("Enter a word\n ") let = raw_input("Enter a letter\n ") count = how_many(let, word) if count == 0: print let, "isn't in", word elif count == 1: print let, "occurs 1 time in", word else: print let, "occurs", count, "times in", word