"""File: most_freq_char.py Purpose: Find the most frequently occurring character a string Run: python most_freq_char.py Input: A string Output: The most frequently occuring character in the string """ 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 #---------------------------------------------------------------------- s = raw_input("Enter a string\n ") most_freq_count = 0 for let in s: count = how_many(let, s) if count > most_freq_count: most_freq = let most_freq_count = count if most_freq_count == 0: print "There aren't any characters in the string you entered!" else: print "The most frequently occurring character is", most_freq print "It occurred", most_freq_count, "times"