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
PostgreSQLv16

Your code output will appear here

Tests12
Visible tests
Hidden test 7
Hidden test 8
Hidden test 9
Hidden test 10
Hidden test 11
Hidden test 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