How to encrypt using 2 keys/keynumbers (Caesar cipher)
<p>How would you encrypt using 2 keys instead of 1 key? It is for school.</p>

<p>So it would ask how much to shift the code by, then ask how many times to shift again, which would shift it even further.</p>

<pre><code>def runProgram():
    def choice():
        userChoice = input('Do you wish to Encrypt of Decrypt? Enter E or D: ').lower()
        if userChoice == "e":
            return userChoice
        elif userChoice == "d":
            return userChoice
        else:
            print("Invalid Response. Please try again.")
            choice()

    def getMessage():
        userMessage = input("Enter your message: ")
        return userMessage

    def getKey():
        try:
            userKey = int(input("Enter a key number (1-26): "))
        except:
            print("Invalid Option. Please try again.")
            getKey()
        else:
            if userKey &lt; 1 or userKey &gt; 26:
                print("Invalid Option. Please try again.")
                getKey()
            else:
                return userKey

    def getPees():
        try:
            userpees = int(input("Enter a key number (1-26): "))
        except:
            print("Invalid Option. Please try again.")
            getpees()
        else:
            if userpees &lt; 1 or userpees &gt; 26:
                print("Invalid Option. Please try again.")
                getpees()
            else:
                return userpees

    def getTranslated(userChoice, message, key):
        translated = ""
        if userChoice == "e":
            for character in message:
                num = ord(character)
                num += key
                translated += chr(num)

                savedFile = open('Encrypted.txt', 'w')
                savedFile.write(translated)
            savedFile.close()
            return translated
        else:
            for character in message:
                num = ord(character)
                num -= key
                translated += chr(num)
            return translated

        def getpranslated(userChoice, message, pees):
            pranslated = ""
        if userChoice == "e":
            for character in message:
                num = ord(character)
                num += key
                pranslated += chr(num)
        else:
            for character in message:
                num = ord(character)
                num -= key
                pranslated += chr(num)
            return pranslated

    userChoice = choice() #Runs function for encrypt/decrypt selection. Saves choice made.
    message = getMessage() #Run function for user to enter message. Saves message.
    key = getKey() #Runs function for user to select key. Saves key choice.
    pees= getPees()
    sqq= getTranslated(userChoice, message, key)#Runs function to translate message, using the choice, message and key variables)
    spp= getTranslated(userChoice, message, pees)
    dranslatedMessage = sqq + spp
    print( 'hi' + int(spp), int(sqq) )
runProgram()
</code></pre>