Caesar Cipher

Lab Python Intermediate 20 points

Read a lowercase message and a shift k. Shift every letter k places forward in the alphabet (wrapping z→a). Leave other characters unchanged.

Input

Line 1: message. Line 2: integer k (0–25).

Output

The encoded message.

Example

Input

hello world
3

Output

khoor zruog
Sample input available Sample output available
Editor
Python

Hints

ord(ch) gives a character's code; chr(n) turns a code back into a character.

Work with positions 0-25: ord(ch) - ord("a"), add k, then % 26.

Solution explanation

Converting letters to 0–25, adding the shift modulo 26, and converting back makes the alphabet wrap around.

Show solution
msg = input()
k = int(input())
result = ""
for ch in msg:
    if "a" <= ch <= "z":
        result += chr((ord(ch) - ord("a") + k) % 26 + ord("a"))
    else:
        result += ch
print(result)
Output
Answer
HOME LEARN COMMUNITY DASHBOARD