alphabet = "abcdefghiklmnopqrstuvwxyz"
encoded = []
def extChar(texto):
if texto:
encode(texto[0])
encode(extChar(texto[1:]))
def encode(char):
if char:
if alphabet.find(char) <= 5:
encoded.append((1, alphabet.find(char) + 1))
elif alphabet.find(char) <= 10:
encoded.append((2, (alphabet.find(char) + 1) - 5))
elif alphabet.find(char) <= 15:
encoded.append((3, (alphabet.find(char) + 1) - 10))
elif alphabet.find(char) <= 20:
encoded.append((4, (alphabet.find(char) + 1) - 15))
elif alphabet.find(char) <= 25:
encoded.append((5, (alphabet.find(char) + 1) - 20))
def main():
data = raw_input("> ")
if data == "j":
data = "i"
extChar(data)
print encoded
if __name__ == '__main__':
main()
SaludosScript para cifrar usando polybios.