cipher encoding

Corey Richardson kb1pkl at aim.com
Wed Jan 12 19:39:14 EST 2011


On 01/12/2011 07:35 PM, Cathy James wrote:
> Dear all,
>  
> I hope someone out there can help me.
>  
>  The output string of my code is close to what i need, but i need it
> 1)printed on one line and
> 2) reversed
>  
> #mycode:
> s= input("Enter message: ")
> key=1
> for letter in s:
>     num=(chr(ord(letter)+1))
>     print(num)
> #or is there a better way to rewrite it with elementary level Python,
> which happens 2b my current ranking.
> #Your insight is always appreciated:)
> 

s = input("Enter message: ")
key = int(input("Enter offset: ")) # I think that's what you wanted
for letter in s:
    print(chr(ord(letter) + key), end = "")




More information about the Python-list mailing list