"""
# TODO
Lesson Objective(s):
Use the .upper function
Use loops with strings
Use lists with strings

Lesson:
Write a program that lets the user enter a string and displays the letter that appears most frequently in the string.
Ignore spaces, punctuation, and uppercase vs lowercase.


Hints:

Create a list to hold letters based on the length of the user input
Convert all letters to the same case
Use a loop to check for each letter in the alphabet (create an alphabet list and step through it)
Have a variable to hold the largest number of times a letter appears,
and replace the value when a higher number is found

"""


def main():
    # data needed
    frequent_letter = ""
    frequency = 0
    count = 0
    alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
                'U', 'V', 'W', 'X', 'Y', 'Z']

    user_string = input("Please enter a phrase to have the most frequently used letter calculated: ")

    # processing
    for letter in alphabet:
        for character in user_string.upper():
            if letter == character:
                count += 1
        if count > frequency:
            frequency = count
            frequent_letter = letter
            count = 0
        elif count == frequency:
            frequent_letter += letter
            count = 0
        else:
            count = 0

    # output
    print("The most frequently used letter(s) is/are: " + frequent_letter)
    print("Your most frequently used letter(s) was/were used " + str(frequency) + " times each")


main()
