[Tutor] comapring lists

Jim De Caro jjd278 at psu.edu
Tue Nov 16 05:39:16 CET 2004


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.  Any suggestions?

Thanks
Jim DeCaro
Microsoft Certified Systems Engineer
Windows 2000 - Windows NT 4.0 + Internet


More information about the Tutor mailing list