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

Le résultat de l'exécution du code s'affichera ici

Visible tests
1
Input
"abc", 1
Expected"bcd"
2
Input
"xyz", 3
Expected"abc"
3
Input
"Hello, World!", 3
Expected"Khoor, Zruog!"
4
Input
"ABC", 0
Expected"ABC"
5
Input
"zZ", 1
Expected"aA"
6
Input
"Python", 13
Expected"Clguba"
Focus radio
Paused · SomaFM · Fluid