In [4]:
alphabet = "abcdefghijklmnopqrstuvwxyz"
input_text = "twas"
cipher_key = 15

cipher_text = ""

character = input_text[0]
character_position = alphabet.find(character)
new_position = character_position + cipher_key
if new_position >= len(alphabet):
    new_position = new_position - len(alphabet)
new_letter = alphabet[new_position]
cipher_text = cipher_text + new_letter
print(cipher_text)

character = input_text[1]
character_position = alphabet.find(character)
new_position = character_position + cipher_key
if new_position >= len(alphabet):
    new_position = new_position - len(alphabet)
new_letter = alphabet[new_position]
cipher_text = cipher_text + new_letter
print(cipher_text)

character = input_text[2]
character_position = alphabet.find(character)
new_position = character_position + cipher_key
if new_position >= len(alphabet):
    new_position = new_position - len(alphabet)
new_letter = alphabet[new_position]
cipher_text = cipher_text + new_letter
print(cipher_text)

character = input_text[3]
character_position = alphabet.find(character)
new_position = character_position + cipher_key
if new_position >= len(alphabet):
    new_position = new_position - len(alphabet)
new_letter = alphabet[new_position]
cipher_text = cipher_text + new_letter
print(cipher_text)
i
il
ilp
ilph
In [6]:
alphabet = "abcdefghijklmnopqrstuvwxyz"
input_text = "twas brillig in the slithy tove"
cipher_key = 15

cipher_text = ""

for character in input_text:
    character_position = alphabet.find(character)
    new_position = character_position + cipher_key
    if new_position >= len(alphabet):
        new_position = new_position - len(alphabet)
    new_letter = alphabet[new_position]
    cipher_text = cipher_text + new_letter
    print(cipher_text)
i
il
ilp
ilph
ilpho
ilphoq
ilphoqg
ilphoqgx
ilphoqgxa
ilphoqgxaa
ilphoqgxaax
ilphoqgxaaxv
ilphoqgxaaxvo
ilphoqgxaaxvox
ilphoqgxaaxvoxc
ilphoqgxaaxvoxco
ilphoqgxaaxvoxcoi
ilphoqgxaaxvoxcoiw
ilphoqgxaaxvoxcoiwt
ilphoqgxaaxvoxcoiwto
ilphoqgxaaxvoxcoiwtoh
ilphoqgxaaxvoxcoiwtoha
ilphoqgxaaxvoxcoiwtohax
ilphoqgxaaxvoxcoiwtohaxi
ilphoqgxaaxvoxcoiwtohaxiw
ilphoqgxaaxvoxcoiwtohaxiwn
ilphoqgxaaxvoxcoiwtohaxiwno
ilphoqgxaaxvoxcoiwtohaxiwnoi
ilphoqgxaaxvoxcoiwtohaxiwnoid
ilphoqgxaaxvoxcoiwtohaxiwnoidk
ilphoqgxaaxvoxcoiwtohaxiwnoidkt
In [ ]: