Going Crazy over Coded_correspondence program bug >.>

Dear Community,
im going insane trying to fix this program. ive been awake till 9 am now and i finally give up on my code. please help?

this is the coded correspondance lesson project.
https://www.codecademy.com/courses/learn-python-3/informationals/python3-coded-communication

only the first word of the 2nd cipher type is translated properly, every other word going ham.

here is my code:

def encoder(message, offset):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    c_message = ""
    for character in message:
        if character in alphabet:
            index = alphabet.find(character)
            c_index = index - int(offset)
            c_message += alphabet[c_index]
        else:
            c_message += character
    return c_message
encoder("i hate this.. im so bad at it.", 2)

#returns the offset of each letter in a keyword as another keyword
def offset_getter(keyword):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    keyword_indicies = []
    
    for letter in keyword:
        
            keyword_indicies.append(alphabet.find(letter))
            
    return keyword_indicies
print(offset_getter("fri"))
print(offset_getter("aruw"))
        

def decoder2(message, keyword):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    punctuation = "?><,.\'/*-="
    true_message = ""
#creates a list of the words in a cypher    
    message_split = message.split()
#will contain the keyword molded to the cypher format
    keyword_mask = []
#creates the mask    
    for word in message_split:
        while len(keyword) < len(word):
            keyword += keyword
        keyword_mask.append(keyword[:len(word)])
#use offset_getter() to get the offsets of keyword
    keyword_offset = [offset_getter(word) for word in keyword_mask]

    
    for word in message_split:
        key = keyword_offset[message_split.index(word)]
        for letter in word:
            if letter in punctuation:
                true_message += letter
            elif letter in alphabet:
                true_message += encoder(letter, key[word.index(letter)])
        true_message += " "
       
    
            
            
    return(true_message)
print(decoder2("dfc aruw fsti gr vjtwhr wznj? vmph otis! cbx swv jipreneo uhllj kpi rahjib eg fjdkwkedhmp!", "friends"))

i tried omitting unnecessary code to avoid confusion but if you want my full code here it is :

alphabet = "abcdefghijklmnopqrstuvwxyz"
message_cryptic = "xuo jxuhu! jxyi yi qd unqcfbu ev q squiqh syfxuh. muhu oek qrbu je tusetu yj? y xefu ie! iudt cu q cuiiqwu rqsa myjx jxu iqcu evviuj!"
true_message = ""
for character in message_cryptic:
    if character in alphabet:
        index = (alphabet.find(character) + 10) % 26
        true_message += alphabet[index]
    else:
        true_message += character
print(true_message)


message_pending = "hi bro! it was very hard.."
alphabet = "abcdefghijklmnopqrstuvwxyz"
c_message = ""
for character in message_pending:
    if character in alphabet:
        index = alphabet.find(character)
        c_index = index - 10
        c_message += alphabet[c_index]
    else:
        c_message += character
print(c_message)
    
def decoder(message, offset):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    true_message = ""
    for character in message:
        if character in alphabet:
            index = (alphabet.find(character) + offset) % 26
            true_message += alphabet[index]
        else:
            true_message += character
    return true_message
decoder("jxu evviuj veh jxu iusedt cuiiqwu yi vekhjuud.", 10)
decoder("bqdradyuzs ygxfubxq omqemd oubtqde fa oapq kagd yqeemsqe ue qhqz yadq eqogdq!", 14)
decoder("g fyrc rfgq.. gk qm zyb yr gr.", 2)



def encoder(message, offset):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    c_message = ""
    for character in message:
        if character in alphabet:
            index = alphabet.find(character)
            c_index = index - int(offset)
            c_message += alphabet[c_index]
        else:
            c_message += character
    return c_message
encoder("i hate this.. im so bad at it.", 2)

#returns the offset of each letter in a keyword as another keyword
def offset_getter(keyword):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    keyword_indicies = []
    
    for letter in keyword:
        
            keyword_indicies.append(alphabet.find(letter))
            
    return keyword_indicies
print(offset_getter("fri"))
print(offset_getter("aruw"))
        

def decoder2(message, keyword):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    punctuation = "?><,.\'/*-="
    true_message = ""
#creates a list of the words in a cypher    
    message_split = message.split()
#will contain the keyword molded to the cypher format
    keyword_mask = []
#creates the mask    
    for word in message_split:
        while len(keyword) < len(word):
            keyword += keyword
        keyword_mask.append(keyword[:len(word)])
#use offset_getter() to get the offsets of keyword
    keyword_offset = [offset_getter(word) for word in keyword_mask]

    
    for word in message_split:
        key = keyword_offset[message_split.index(word)]
        for letter in word:
            if letter in punctuation:
                true_message += letter
            elif letter in alphabet:
                true_message += encoder(letter, key[word.index(letter)])
        true_message += " "
       
    
            
            
    return(true_message)
print(decoder2("dfc aruw fsti gr vjtwhr wznj? vmph otis! cbx swv jipreneo uhllj kpi rahjib eg fjdkwkedhmp!", "friends"))

is space different from other non-letters for your algorithm?

you’re carrying out a bunch of steps, you could write out messages from your code how the decisions are made and what you have after each action, this would give you a way to observe what is being done and tell you where it goes wrong

I have done that, i even traced the function on paper :’(

I did add at the end of my decoder2 function a space adding mechanism between list items so that output comes out as a sentence

every single detail in what you’re doing is observable

if you wrote everything out and what you wrote out is all correct… then the end result is correct too. more likely though, what you wrote out was the wrong thing or incomplete or insufficient detail. you’d need to write out the things that the correct result relies on

a good place to start might be what all the incoming letter/key pairs are. are you getting the correct pairs, and is the decoding of each pair correct?
there aren’t all that many options to what can go wrong. you can get wrong input in which case you’d continue looking at whatever prodeuced that. you can have correct input and correct output, in which case it’s whatever comes next, or you can have correct input but wrong output, in which case the decoding is done wrong
regardless of which it is, that observation tells you a lot about where the problem is and where to continue to make further observations