"""This is assignment 0. The point is to write a simple Python 
program that does some simple string manipulations. """

while True:
    # Prompt for user input.
    inp = input( "\nPlease enter a string: " )
    if ( inp == "" ): break
    
    # Print the input, an uppercase version, and a lowercase version.
    print ( "User's input: ", inp )
    print ( "In uppercase: ", inp.upper() )
    print ( "In lowercase: ", inp.lower() )

    # Count occurences of the letters a-z
    counts = [0] * 26
    for c in inp.lower():
        if c.isalpha():
            index = ord(c) - ord("a")
            counts[index] += 1

    # Print the letter counts.
    print ( "The input contains the following characters:")
    for i in range(26):
        print ( "   " + chr (i + ord('a')) + ":", counts[i])

    # Apply Caesar cipher with a shift of one position. 
    caesar = ""
    for c in inp.lower():
        if ( c == "z" ):
            caesar += "a"
        elif c.isalpha():
            caesar += (chr (ord(c) + 1))
    print ( "Using the Caesar cipher:", end=" ")
    print (caesar)

        

