How to reverse lookup characters in list?

tjland at iserv.net tjland at iserv.net
Mon Jul 28 00:15:35 EDT 2003


Okay so im working on a very simple encryption method using just loops.
Kind of novel i think. Okay so first i set up a list of the alphabet with
just every seperate letter, then user is prompted for a word, this is not
user friendly just for me. Ok now as you can see below this is pretty
basic, if u can follow all the loops i get to a point where I have the
letter positions in the list for the final word but i dont know of a way
to come back with the corresponding letter to output to the user. Ummm
some help would be really appreciated. Sorry about the length!


----------------------------------------------------------------------------
from time import sleep
#Alphabet list used to move letters forward for simple encryption.
alphabet =
["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"]

word_list = []
number_list = []
number_list2 = []
new_word = []
#variable for how far you want to switch
v = 2
word = raw_input("Word: ")
a = len(word)
for x in range(0, len(word)):
    print word[x],
    word_list.append(word[x])
    b = alphabet.index(word[x])
    number_list.append(b)

for x in range(0, len(number_list)):
    c = number_list[x]
    c = c + v
    number_list2.append(c)

for x in range(0, len(number_list2)):
    d = number_list2[x]
    new_word.append(d)

for x in range(0,
#Stopped here because dont know of way to switch back.
----------------------------------------------------------------------------



         When you see the net take the shot
         When you miss your shot shoot again
           When you make your shot you win!

                   Just remember
               Offense sells tickets
           But defense wins championships!





More information about the Python-list mailing list