Hi, I give up. This method is too time-consuming and inflexible. It’s unacceptable to spend hours trying to find a solution when the result is correct. It would be helpful to point out the expression that doesn’t fit. Best regards
Can you please post your code and the url of the step so we can consider whether the solution is incorrect.
Here is my code. It's step 23. For me it seems correct ...
def caesar(text, shift, encrypt=True):
if not isinstance(shift, int):
return 'Shift must be an integer value.'
if shift < 1 or shift > 25:
return 'Shift must be an integer between 1 and 25.'
alphabet = 'abcdefghijklmnopqrstuvwxyz'
if not encrypt:
shift = - shift
shifted_alphabet = alphabet[shift:] + alphabet[:shift]
translation_table = str.maketrans(alphabet + alphabet.upper(), shifted_alphabet + shifted_alphabet.upper())
encrypted_text = text.translate(translation_table)
return encrypted_text
def encript(text, shift):
return caesar(text, shift)
def decript(text, shift):
return caesar(text, shift, False)
Regards
Hi
Your result is not correct as you haven’t spelled the function names exactly as asked.
Thanks! But it doesn’t really matter what the functions are called, but okay…
It does matter if you want to pass the tests.
1 Like