Vigenere cipher project

Hey there,

I’m currently working on the off-platform project coded correspondence. Unfortunately I’m stuck with the last problem of decoding a Vigenere Cipher.
I’d really appreciate any help on my problem!
I’m using the following function to decode the message:

Alphabet = 'abcdefghijklmnopqrstuvwxyz' def vigenere_decode(message, keyword): decoded_message = '' # these are single quotation marks k = 0 for i in range(len(message)): if message[i] in Alphabet: # using modulo to make sure that index is in range for the keyword and for the alphabet decoded_message += Alphabet[(Alphabet.index(message[i]) + Alphabet.index(keyword[k % len(keyword)])) % len(Alphabet)] # since the character was in the alphabet i raise k by 1 k += 1 else: # skipping the characters that are not in the alphabet but still adding them to the decoded message decoded_message += message[i] return decoded_message extr_message = 'dfc aruw fsti gr vjtwhr wznj? vmph otis! cbx swv jipreneo uhllj kpi rahjib eg fjdkwkedhmp!' first_key = 'friends' print(vigenere_decode(extr_message, first_key))

Thanks so much!
Best regards

Change the + to be -

1 Like