I'm trying to make a "Caesar's Cipher" while using python..this is what I have so far. Could anyone tell me how this is looking? Am I going in the right direction? What am I missing? When I run the program to say for example (josh is cool) I don't get the cipher on the same line. It looks like this when I do main(3)
m
r
v
k
l
v
f
r
r
o
But it puts each letter on a new line. How could I do it so that it is on one line?
def main(k):
if k<0 or k>231:
print "complaint"
raise SystemExit
Input = raw_input("Please enter Plaintext to Cipher")
for x in range(len(Input)):
letter=Input[x]
if letter.islower():
x=ord(letter)
x=x+k
if x>122:
x=x-122+97
print chr(x),
if letter.isupper():
x=ord(letter)
x=x+k
if x>90:
x=x-90+65
print chr(x),
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…