Home » Python » Python program » Frequancy of Character
Python program frequancy of characters in a string
# Author: CppBuzz.com
# This program find characters frequency in the given string
# Date: 22nd Aug 2020
def charFrequency(userInput): userInput = userInput.lower() # covert string to lowercase dict = {} for char in userInput: keys = dict.keys() if char in keys: dict[char] += 1 else: dict[char] = 1 return dict if __name__ == '__main__': userInput = str(input("Enter any string: ")) print(charFrequency(userInput))