Saturday, 14 September 2013

caesar cipher problems in python

caesar cipher problems in python

I have the following code which gives me error saying it cannot convert
'int' object to str implicitly. the if statements were used so if a letter
in WORD is ascii 125 and i had to shift it by 5, I wanted the shift to
goto ascii 32 and calculate. if any of the letters in word was less than
ascii 32 shift, then shift to 32.
word=input("enter something to encrypt")
offset=int(input("Enter a number to shift it by"))
for char in word:
newword= ord(char)
newword =newword+ chr(newword) + offset
if newwword<32:
result=result+95
elif newword >126:
result=result-95

No comments:

Post a Comment