def letterFrequency(): newString = raw_input( "Type the string here: " ) #Convert to lowercase mod_string = newString.lower() #Initialize lists to store the new data in data = [] new_data = [] count = 0 #Check only for characters in the given string for s in 'abcdefghijklmnopqrstuvwxyz': count = 0 for char in mod_string: if s == char: count += 1 data = [ s, count ] new_data += [ data ] return new_data print letterFrequency()