Help explain why this code works?

This is a solution on how to decode a Vigenère cypher. Can someone explain to me why this code works?

alphabet = "abcdefghijklmnopqrstuvwxyz"
punctuation = ".,?'! "

def vigenere_decoder(coded_message, keyword):
    letter_pointer = 0
    keyword_final = ''
    for i in range(0,len(coded_message)):
        if coded_message[i] in punctuation:
            keyword_final += coded_message[i]
        else:
            keyword_final += keyword[letter_pointer]
            letter_pointer = (letter_pointer+1)%len(keyword)
    translated_message = ''
    for i in range(0,len(coded_message)):    
        if not coded_message[i] in punctuation:
            ln = alphabet.find(coded_message[i]) - alphabet.find(keyword_final[i])
            translated_message += alphabet[ln % 26]
        else:
            translated_message += coded_message[i]
    return translated_message

message = "dfc aruw fsti gr vjtwhr wznj? vmph otis! cbx swv jipreneo uhllj kpi rahjib eg fjdkwkedhmp!"
keyword = "friends"

print(vigenere_decoder(message, keyword))

Any help would be appreciated!

Doesn’t the code say what it does? I don’t understand what you’re asking. Is it surprising that it works? Think it should do something else?

Maybe you really mean you don’t know what a for-loop does, or something like that.

Buddy don’t mean to be rude, but after reading several of your posts, I feel like you’re just clicking the GIVE SOLUTION button on the lessons. The lessons explain all of this.
If you’re not, I’m sorry I don’t mean to be rude.