I am coding a ceaser cipher for my AP Computer science class but its not working. can someone please help.
The link to the code
Cypher.py
It’s not working because???
check below code , this is will do shift three only (i know there user input ) but later i will update it
import string
x = raw_input("inter a masseg to dycrept or incrept-->")
y = raw_input("incrypt = i dycrept = d -->")
x = x.lower()
y = y.lower()
#------------script start-------------------------------------
def inc(x):
result = []
for i in x:
try:
o = string.ascii_lowercase.index(i)
result.append(string.ascii_lowercase[o+3])
except:
if i == 'x':
result.append("a")
elif i == 'y':
result.append("b")
else:
result.append("c")
return result
def dyc(x):
result = []
for i in x[:]:
try:
o = string.ascii_lowercase.index(i)
result.append(string.ascii_lowercase[o-3])
except:
if i == 'a':
result.append("x")
elif i == 'b':
result.append("y")
else:
result.append("z")
return result
if y == "i":
print ''.join(inc(x))
if y == "d":
print ''.join(dyc(x))