Coded Correspondence off platform project step 2

Dear community,

I’m working on the Off-platform Project: Coded Correspondence and I’m having some trouble in step 2/3
So I’m supposed to make a ‘coder’ function that takes a message as an argument and codes it with an offset

This is my coder and decoder function:

alphabet = "abcdefghijklmnopqrstuvwxyz" punctuation = ".,?'! " def code_message(msg, offset): coded_message = " " for letter in msg: if not letter in punctuation: coded_value = alphabet.find(letter) coded_message += alphabet[(coded_value - offset) % 26] else: coded_message += letter return print(coded_message) code_message("Can someone help me figure this problem out? Because I cannot", 10) def decoder(msg, offset): translated = "" for letter in msg: if not letter in punctuation: letter_value = alphabet.find(letter) translated += alphabet[(letter_value + offset) % 26] else: translated += letter return print(translated) decoder("pqd iecuedu xubf cu vywkhu jxyi fherbuc ekj? pusqkiu p sqddej", 10)

If you run this codebyte you will see I’ll get a few random z’s is my decoded message, and I don’t understand where I’ve made the mistake. Also I couldn’t find the difference between my function and the solution function

I’m doing this project in Visual Studio Code in case that matters.

Please let me know if I forgot to add any important information.
I’d appreciate any help

Your code is essentially correct, but it doesn’t account for capital letters. Every capital letter turns into a “p”, which when decoded is a ‘z’.

Thanks! It seems you’re correct! Do you have any idea what the best way to fix it is? First thing that comes to my mind is making the message all lowercase with the .lower method, but I’m not sure if this is the best way

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