[Tutor] comapring lists

Bob Gailer bgailer at alum.rpi.edu
Mon Nov 29 20:30:40 CET 2004

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 =
>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 

More information about the Tutor mailing list