In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of December 7th
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #08 exercise sheet]


In this problem you should submit a function as described. Inside the function do not print anything that was not asked!

[IP078] Secret Message

Jaime Lannister, the famous knight of the Kingsguard, needs to send a secret message to his army stationed at the battlefront. To ensure that the message remains confidential if intercepted, Jaime decides to use the Caesar cipher, a simple encryption technique. In a Caesar cipher, each letter in the plaintext is shifted a fixed number k of places down the alphabet.

Imagine for instance that k=10. Then the following letter substitions would occur (with each letter becoming the letter 10 positions to the left in the alphabet, wrapping around):

old letter: abcdefghijklmnopqrstuvwxyz
new letter: klmnopqrstuvwxyzabcdefghij

For example, with his k, "attack" would become "kddkmu".

The Problem

Write a function caesar_cipher(text, k) that given a string text, returns a string that is equivalent to the text with all (lowercase) letters shifted to the right by k positions, as previously explained. Non-alphabetic characters (e.g., digits, punctuation, spaces) should remain unchanged.

Constraints

The following limits are guaranteed in all the test cases that will be given to your program:

1 ≤ |text| ≤ 200       length of text
1 ≤ k ≤ 25       number of positions to shift

You can also be assured that all letters in the word are in lowercase.


Example Function Calls Example Output
print(caesar_cipher("attack the starks", 10))
print(caesar_cipher("winteriscoming", 23))
print(caesar_cipher("tfkqbofpzljfkd", 3))
kddkmu dro cdkbuc
tfkqbofpzljfkd
winteriscoming

Introduction to Programming (CC1024)
DCC/FCUP - University of Porto