Vicenere Cipher Project (2nd Problem)

It works properly unless the encoded message has a space. Instead of desired output “barry is” it outputs “barry fd”. If the encoded_message has not spaces or special characters, it works as desired “barryis”. I need to be able to negotiate spaces in the encoded message. Any suggestions, thanks in advance.

“”"
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
dictionary = {}
reverse_dictionary = {}

for i in range(0, len(alphabet)):
dictionary[i] = alphabet[i]

reverse_dictionary = {value: key for key, value in dictionary.items()}

def vigenere_cipher(keyword, encoded_message):
keyword_phrase = ‘’
decoded_message = ‘’
counter = 0
for i, char in enumerate(encoded_message):
if char.isalpha():
x = keyword[i % len(keyword)]
keyword_phrase += x
else:
keyword_phrase += char
for y, z in zip(encoded_message, keyword_phrase):
if y in alphabet:
decode_index = (alphabet.index(y) + reverse_dictionary[z]) % len(alphabet)
decoded_message += alphabet[decode_index]
counter += 1
else:
decoded_message += encoded_message[counter]
return decoded_message
vigenere_cipher(‘dog’, ‘ymlokcp’)
“”"