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
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
"abc", 1Expected
"bcd"2
Input
"xyz", 3Expected
"abc"3
Input
"Hello, World!", 3Expected
"Khoor, Zruog!"4
Input
"ABC", 0Expected
"ABC"5
Input
"zZ", 1Expected
"aA"6
Input
"Python", 13Expected
"Clguba"Focus radio
Paused · SomaFM · Fluid