The Vigenère Cipher => why generate a keyword phrase that is the same length as the message instead of using an index list?

Hello, i have a question about Step 5: The Vigenère Cipher from the Off-Platform Project: Coded Correspondence.

Why would you “generate a keyword phrase that is the same length as the message we want to code” if you could decipher as follows:


def decoder(msg, keyword):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    keyword_char_indexes = []
    counter = 0
    decoded_msg = ""

    for key_char in keyword:
        keyword_char_indexes.append(alphabet.find(key_char))

    for char in msg:
        if char not in alphabet:
            decoded_msg += char
        else:
            if counter == len(keyword):
                counter = 0
            decoded_char = alphabet[(alphabet.find(char) + keyword_char_indexes[counter]) % 26]
            decoded_msg += decoded_char
            counter += 1

    return decoded_msg


print(decoder("txm srom vkda gl lzlgzr qpdb? fepb ejac! ubr imn tapludwy mhfbz cza ruxzal wg zztcgcexxch!", "friends"))