Coded Correspondence - Hard?

Hey guys I was struggling for a good 2 - 3 weeks to solve this exercise longest i spend on an exercise , current exc specifically the last one was Vigenere cipher

I wouldn’t be able to solve it if it weren’t for GPT3 altho gpt itself keeps giving me inadequate answers for this task, i tried my best to solve it by myself and asking basic questions in the end this is my final output

message = "txm srom vkda gl lzlgzr qpdb? fepb ejac! ubr imn tapludwy mhfbz cza ruxzal wg zztcgcexxch!"
keyword = "friends"
keywordphrase = ""
keyword_index = 0
alpha = "abcdefghijklmnopqrstuvwxyz"
decoded = ""
message_index = 0
#get indices of characters ie. t=0 x=1...
while len(decoded) < len(message):
    letter = message[message_index]
    letter2 = keyword[keyword_index]
    message_index = (message_index + 1) % len(message)
  #index letters to corresponding alphabete
    if letter in alpha:
        letter_index = alpha.index(letter)
        letter2_index = alpha.index(letter2)
     

        # Calculate the backward shift value for the Vigenere cipher
        shift = (letter_index + letter2_index) % 26

        

        # Apply the backward shift to the character in the message and add it to the decoded message
        decoded += alpha[shift]

        # Move to the next character in the message and keyword
        
        keyword_index = (keyword_index + 1) % len(keyword)
     
# if space or non alphabete revert to original  letter
    else:
        decoded  += letter
        
print(decoded)

i had a hard time also figuring out that i was supposed to put message_index = (message_index + 1) % len(message) in my while loop instead of putting in inside the if loop as it was only outputting “you”

Since i had a hard time, actually solving it , i’m thinking of learning the solution by heart, so whenever i need to decipher something i use this way until i understand everything comfortably… i guess with more exercises , is that ok? do i really need to be able to solve this task all by myself without any help at this stage?

did you struggle too? if so what helped you?
I just don’t know if i have to start again everything from the beginning or just continue my python course

update i noticed the solution was different than my code, after analysing it , i do understand the process used but got a hard time solving it myself without some hints. As solving these problems requires you to think differently