diff --git a/lab2/cse16259_e2_9.py b/lab2/cse16259_e2_9.py new file mode 100644 index 0000000000000000000000000000000000000000..7b8cfdb421b784c422bd925681bdc2ac36e7ab98 --- /dev/null +++ b/lab2/cse16259_e2_9.py @@ -0,0 +1,14 @@ +def encrypt(text,s): + result = "" + for i in range(len(text)): + char = text[i] + if (char.isupper()): + result += chr((ord(char) + s-65) % 26 + 65) + else: + result += chr((ord(char) + s - 97) % 26 + 97) + return result +text=input("enter the sentence to encrypt: ") +s=int(input("enter the no of shift locations to do: ")) +print("given text: "+text) +print("Shift locations: "+str(s)) +print("encrypted text: " +encrypt(text,s))