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
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesTests12
Visible tests
Slēptais tests 7
Slēptais tests 8
Slēptais tests 9
Slēptais tests 10
Slēptais tests 11
Slēptais tests 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