Liam Clarke | 1 Dec 2004 02:19
Picon

Re: comapring lists

Looking at the two dictionaries, he's offsetting by 1?

How about to encrypt - 

x=""
y=raw_input('Enter phrase to crypt like')

for item in y:
     a=ord(item)+1
     x += chr(a)

To decrypt - 

x1=""

for item in x:
    a=ord(x)-1
     x1 += chr(a)

On Mon, 29 Nov 2004 12:30:40 -0700, Bob Gailer <bgailer <at> alum.rpi.edu> wrote:
> At 09:39 PM 11/15/2004, Jim De Caro wrote:
> 
> 
> >I am getting user input and comparing it to an iterated list.  I can get the
> >input to print out verbatim.  I want to then "swap" individual letters in the
> >input with letters from a second list so it is like a simple encryption.  I
> >can't figure out the correct logic or syntax.  Here is what I have so far:
> >
> >user = raw_input("Enter your selection: ")
> >
> >
> >
> >encrypt =
> >['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9','0']
> >
> >decrypt
> >=['b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','0','1','2','3','4','5','6','7','8','9','0']
> >
> >
> >for i in range(len(encrypt)):
> >         print user[0:62]
> >         break
> >
> >for j in range(len(decrypt)):
> >     for j in zip(decrypt):
> >         print 'Encrypted-> %s' % (j,user)
> >         break
> >
> >This does not work.
> 
> "does not work" is not helpful. We'd rather hear what results you are
> getting (if any) and (if needed) how they differ from what you expect.
> 
> The code above does nothing useful. It is hard to even begin to diagnose
> it. But get rid of the break statements. They cause the loops to end after
> 1 iteration.
> 
> Is this a homework problem?
> 
> Can you write a pseudocode version of what you think the program should
> look like?
> 
> Bob Gailer
> bgailer <at> alum.rpi.edu
> 303 442 2625 home
> 720 938 2625 cell 
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor <at> python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

--

-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor


Gmane