Coded Correspondance

Hi and thanks,
i’m a begginer in python and i’m tyring coded correspondace strings chapter. I understand about Caesers and solves. but vigenere are more confused.
could you help with this:

<alphabet = “abcdefghijklmnopqrstuvwxyz”
cipher_msg = “dfc aruw fsti gr vjtwhr wznj? vmph otis! cbx swv jipreneo uhllj kpi rahjib eg fjdkwkedhmp!”
keyword = “friends”

for i in range(0,len(cipher_msg)):
if (cipher_msg[i]==" ") or (cipher_msg[i] == “=”) or (cipher_msg[i] == “?”) or (cipher_msg[i] == “!”) or (cipher_msg[i] == “.”):
un_cipher+= cipher_msg[i]

elif (cipher_msg[i] != " ") or (cipher_msg[i] != "=") or (cipher_msg[i] != "?") or (cipher_msg[i] != "!") or (cipher_msg[i] != "."):
        pos = ((alphabet.find(cipher_msg[i])-alphabet.find(keyword[i]))%26)
        un_cipher += alphabet[pos]

print (un_cipher)

am not sure what am doing bad.

try changing the elif stuff to else (but with no condition)

Also note that the complement to
(a == 1) or (b == 2)
(a != 1) and (b != 2)
That’s part of De Morgan’s laws in math, I think.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.