choice2 = input("Encrypt(e) or Decrypt(d): ")
cipherlist = []
keylist= []
key = input("Input a key: ")
key = key + 'abcdefghijklmnopqrstuvwxyz'
removedDups ="".join(OrderedDict.fromkeys(key))
for val in range(5):
dupslice = removedDups[(val*5):((val+1)*5)]
keylist = list(dupslice)
cipherlist.append(keylist)
#encrypt playfair
if choice2 == 'e':
plaintext = input('Input text to be encrypted: ')
for val in range(len(plaintext)):
diaplain = plaintext[(val*2):((val+1)*2)]
plainltr1 = diaplain[0:1]
plainltr2 = diaplain[1:2]
(c1, r1) =index_2d(cipherlist, plainltr1)
(c2,r2) =index_2d(cipherlist, plainltr2)
I am getting a cannot unpack non-iterable NoneType object error on lines:
(c1, r1) =index_2d(cipherlist, plainltr1) and (c2,r2) =index_2d(cipherlist, plainltr2).
For some reason if I print(cipherlist) before asking for the index it works. Oh I almost forgot, the function I am using for index:
def index_2d(alist, ltr):
for y, x in enumerate(alist):
if ltr in x:
return (y, x.index(ltr))
Thanks so much!! I am stumped as why to this is happening.