Editorial for Caesar Encryption


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: wadeyao

import string
t = int(input())
for i in range(1,t+1):
    s = input()
    ans = ''
    for c in s:
        if c in string.ascii_lowercase:
            ans += chr(ord('a') + (((ord(c) - ord('a'))+1)%26))
        elif c in string.ascii_uppercase:
            ans += chr(ord('A') + (((ord(c) - ord('A'))+1)%26)) 
        else:
            ans+=c
    print(f'Case #{i}: {ans}')

Comments

There are no comments at the moment.