Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from string import ascii_uppercase, ascii_lowercase
- try:
- k = int(input())
- inputStr = input()
- result = ""
- for i in range(0, len(inputStr)):
- if ord(inputStr[i]) > 64 and ord(inputStr[i]) < 92:
- encryptedPos = (ord(inputStr[i]) - 65) + k
- encryptedIndex = encryptedPos if encryptedPos < len(ascii_uppercase) else encryptedPos - len(ascii_uppercase)
- result += ascii_uppercase[encryptedIndex]
- elif inputStr[i] in ascii_lowercase:
- result = "INVALID INPUT"
- break
- else:
- result += inputStr[i]
- print(result)
- except:
- print("INVALID INPUT")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement