You are viewing a single comment's thread. Return to all comments →
n = int(input().strip()) s = input().strip() k = int(input().strip()) new_str = '' temp = [] for letter in s: if ord(letter) >= 65 and ord(letter) <= 90: temp.append(chr(65 + (ord(letter) - 65 + k) % 26)) elif ord(letter) >= 97 and ord(letter) <= 122: temp.append(chr(97 + (ord(letter) - 97 + k) % 26)) else: temp.append(letter) new_str = new_str.join(temp) print(new_str)
Any better logic?
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher: Encryption
You are viewing a single comment's thread. Return to all comments →
Any better logic?