I have written a small application to encrypt some text. The script looks fine to me, but it won't run and I can't figure out why. I have attached it, if anyone knows why it doesn't work please let me know!
#!/usr/bin/env python3

import random
values = {'a':'d', 'b':'e', 'c':'f', 'd':'g', 'e':'h', 'f':'i', 'g':'j', 'h':'k', 'i':'l', 'j':'m', 'k':'n', 'l':'o', 'm':'p', 'n':'q', 'o':'r', 'p':'s', 'q':'t', 'r':'u', 's':'v', 't':'w', 'u':'x', 'v':'y', 'w':'z', 'x':'a', 'y':'b', 'z':'c', 'A':'D', 'B':'E', 'C':'F', 'D':'G', 'E':'H', 'F':'I', 'G':'J', 'H':'K', 'I':'L', 'J':'M', 'K':'N', 'L':'O', 'M':'P', 'N':'Q', 'O':'R', 'P':'S', 'Q':'T', 'R':'U', 'S':'V', 'T':'W', 'U':'X', 'V':'Y', 'W':'Z', 'X':'A', 'Y':'B', 'Z':'C',

def encrypt():
    textInputE = input('Please enter the text you wish to encrypt: ')
    textInputE.list()
    for Eletter in textInputE.list():
        try:
            print (values[Eletter])
        except KeyError:
            print ('Sorry, that input couldn\'t be parsed as text. Try again.')
            input('Press Enter')
def decrypt():
    textInputD = input('Please enter the numbertext you wish to decrypt')
    textInputD.list()
    for Dletter in textInputD.list():
        try:
            print (values[Dletter])
        except KeyError:
            print ('Sorry, that input couldn\'t be parsed as numbertext from our cipher. Please try again.')
            input('Press Enter')

while True:
    EorD = input('Encrypt or Decrypt: ')
    if EorD == 'Encrypt' or EorD == 'encrypt':
        encrypt()
    elif EorD == 'Decrypt' or EorD == 'decrypt':
        decrypt()
    else:
        print('Encrypt or Decrypt?')
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to