Ip05.py
''' 
Soren DeOrlow 
IDSN 599, Fall 2021 
deorlow@usc.edu 
Lab Practical 5 (revised) 
'''

#import uppercase dictionary from ASCII

#userAlphabet = []
alphabetUcDict = {}
for value in range(65,91):
    alphabetUcDict[chr(value)] = 0
#print(alphabetUcDict)

#import lowercase dictionary from ASCII
alphabetLcDict = {}
for value in range(97,123):
    alphabetLcDict[chr(value)] = 0
#print(alphabetLcDict)

#merge into single alphabet
def merge(alphabetUcDict, alphabetLcDict):
    res = alphabetUcDict | alphabetLcDict
    return res
alphabet = merge(alphabetUcDict, alphabetLcDict)
#print(alphabet)

totalInput = ""
#userSentence = input()

while True:
    userSentence = input("Please write a sentence: ").upper().replace(" ","")
    totalInput += userSentence
    if len(userSentence) == 0: # this statement forces users to enter a sentence
        break
print(totalInput)

finalTotallist = list(totalInput)

    #for letter in totalInput:
        #if letter in alphabet:
            #alphabet[letter] += 1
''' 
def split(totalInput): # this splits the text into characters 
    return list(characters) 
characters = totalInput 
results = split(characters) 
cleanChar = sorted(results) 
userAlphabet = cleanChar 
print(userAlphabet) 
'''
    #if!=0 do not print value.

#count the number of characters in the sentence

    #for char in range(len(cleanChar)):
    #results = ""
print("")
print("Your sentence contains the following character frequency: ")

for letters in finalTotallist:
    for key in alphabet:
        if key == letters:
            alphabet[key] += 1  # this sets a count within the key of each dictionary number

    #print(alphabet)
asterisk = []

for value in range (65,91):
    asterisk = "*" * alphabet[chr(value)]
    if alphabet[chr(value)] != 0:
        print(chr(value), ":", asterisk)  # this converts the count to an asterisk