I have been doing simple programming challenges all day, trying to learn and practice. I however, always seems to fail at efficiency. Without using built_in code (such as the encode method), is there anyway that I could improve my program's efficiency (my efficiency in general)?
import string
alph = string.ascii_lowercase
def encrypt(text):
encryption = ""
for character in text:
index = 0
shift = 0
for letter in alph:
if letter == character:
if index > 23:
shift = abs(26 - (index+3))
encryption += alph[shift]
break
shift = index + 3
encryption += alph[shift]
index += 1
return encryption
def decrypt(text):
decryption = ""
for character in text:
index = 0
shift = 0
for letter in alph:
if letter == character:
if index < 3:
shift = abs(26 - (index+3))
decryption += alph[shift]
break
shift = index - 3
decryption += alph[shift]
index += 1
return decryption