Caesar Shift
The Caesar cipher is a simple way to hide text by shifting every letter through the alphabet by the same number of positions. The function caesar_encrypt receives a string text and a shift value shift. Move each Latin letter forward with wraparound at the end of the alphabet, preserve letter case, and leave spaces, punctuation, and other characters unchanged.
Примеры
Ввод
("abc", 1)Вывод
"bcd"Ввод
("xyz", 3)Вывод
"abc"Ввод
("Hello, World!", 3)Вывод
"Khoor, Zruog!"Нужно реализовать
def caesar_encrypt(text: str, shift: int) -> str:
Теги
strings
Влез, за да видиш историята на решенията
ВходВлез, за да използваш ИИ ментора
ВходTests12
Visible tests
Скрит тест 7
Скрит тест 8
Скрит тест 9
Скрит тест 10
Скрит тест 11
Скрит тест 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid