Stuck on offplatform project: Coded correspondence

Link to the project:
https://www.codecademy.com/courses/learn-python-3/informationals/python3-coded-communication

I’m stuck on the project: coded correspondence. I have it working when there are only letters in the message, but if I add code to account for punctuation, it doens’t work anymore. What am I doing wrong?

It works with this code:

alfabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def test(message):
    list_message = list(message)
    empty_decypher = []
    for x in range(len(list_message)):
        index_alfabet = alfabet.index(list_message[x])
        index_decypher = index_alfabet + 10
        if index_decypher < 26:
            empty_decypher.append(alfabet[index_decypher])
        if index_decypher >= 26:
            index_around = index_decypher % 26
            empty_decypher.append(alfabet[index_around])
    return ''.join(empty_decypher)

print(test('xuo'))

My section to account for punctuation is below, but than I get an error because empty_decypher is [0 , 1, 2] and that is not a string to join. I don’t get why this code would give 012. Can somebody explain this to me?

alfabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def decypher(message):
    list_message = list(message)
    empty_decypher = []
    for x in range(len(list_message)):
        if x not in alfabet:
            empty_decypher.append(x)
        if x in alfabet:
            index_alfabet = alfabet.index(list_message[x])
            index_decypher = index_alfabet + 10
            if index_decypher < 26:
                empty_decypher.append(alfabet[index_decypher])
            if index_decypher >= 26:
                index_around = index_decypher % 26
                empty_decypher.append(alfabet[index_around])
    return ''.join(empty_decypher)
  
print(decypher('xuo'))

I think you mixed up the index (which is an integer number) with the actual letter (character/string) for the x variable.
So

    for x in range(len(list_message)):
        if x not in alfabet:
            empty_decypher.append(x)
        if x in alfabet:
            index_alfabet = alfabet.index(list_message[x])

should be

    for i in range(len(list_message)):
        x = list_message[i]  # get the letter at index i, put letter as x
        if x not in alfabet:
            empty_decypher.append(x)
        if x in alfabet:
            index_alfabet = alfabet.index(x)

where i is the index, and x stores the letter.

The problem was that you used x to hold the index, but you treated that as a variable that holds the letter later.

Thanx for your responses.
I actually figured it out after posting this, but my post was flagged as spam so I coudn’t edit or delete it anymore.

It seems I’m not able to delete this post now anyhow. Do you have an idea on how to delete it?