How can I make each letter in the message to be encoded by replacing it with the letter k positions further in the alphabet?. For example, if k=3, “a” is replaced by “d”, “b” is replaced by “e”, and so on. The alphabet wraps around. “w” is replaced by “z”, “x” by “a”, “y” by “b”, and “z” by “c”. You can assume the message to be encoded is not empty and only contains lower case letters and spaces. A space is encoded as a space. this is what I tried but it doesn't work like it needs to. I need to be able to enter an amount of letters to skip.
def encode(string,keyletter):
alpha="abcdefghijklmnopqrstuvwxyz"
secret = ""
for letter in string:
index = alpha.find(letter)
secret = secret+keyletter[index]
print secret