Python Lists and Dictionaries
Counts number of each character in each sentence, and returns a list of unique characters
sentence = ""
counter = {}#Creates a dictionary to store characters and the number of times they show up
distinct = []#Creates list to store distinct characters
while sentence != "done!":#repeats code till user inputs done
sentence = input("Enter a Sentence")#asks for user input
for i in sentence:
if i not in counter:
counter[i] = 0#for every new letter, create a new entry in the dictionary and add it to the distinct list
distinct.append(i)
counter[i] += 1#add to entry of dictionary
for i in counter:
print(i," : ",counter[i])#prints each entry of dictionary
print(sorted(distinct))#sorts distinct characters in alphabetical order and prints sorted list