Caesar Cipher Program
<pre><code>def caesar_cipher(message):
    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']
    newmessage = ""
    for letter in message:
        if letter in alphabet:
            positionnumber = alphabet.index(letter) + 13
            position = positionnumber % 26
            newmessage += alphabet[position]
        else:
            newmessage += letter
    print(newmessage)
</code></pre>

<p>How can I get this to change capitals as well?</p>

<p>This can be done very efficiently using the <code>ord</code> function. It gives you the ASCII value of a character. Regardless of how you define the alphabet, you simply do separate ciphers for uppercase and lowercase.</p>

<pre><code>def rot13(char):
    """
    Calculate the ROT13 substitute for `char`

    :param char: The character to substitute
    :type char: str
    :returns: The substitute
    :rtype: str
    """
    if ord('a') &lt;= ord(char) &lt;= ord('z'):  # lowercase
        return chr((ord(char) - ord('a') + 13) % 26 + ord('a'))
    elif ord('A') &lt;= ord(char) &lt;= ord('Z'):  # uppercase
        return chr((ord(char) - ord('A') + 13) % 26 + ord('A'))
    raise ValueError('Not an ASCII letter: %r' % char)

def caesar_cipher(message):
    return ''.join(rot13(char) for char in message)
</code></pre>

python