I am coding in Python 2.7 using PyCharm on Ubuntu.
I am trying to create a function that will take a string and change each character to the character that would be
The problem you are solving is of Ceaser cipher. you can implement the formula in your code.
E(x) = (x+n)%26 where x is your text and n will be the shift.
Below is my code. (I write the code in python 3)
import ast
n = ast.literal_eval(input())
n1 = n[0]
step = n[1]
def enc_dec(string,step):
result = ''
for i in string:
temp = ''
if i=='':
result = result+i
elif i.isupper():
temp = chr((ord(i) + step - 65) % 26 + 65)
else:
temp = chr((ord(i) + step - 97) % 26 + 97)
result = result + temp
return result
print(enc_dec(n1,step))