3 AnswersNew Answer
Your dict has all keys as single letters. If you input more than 1 letter, you will get a Key error, because there is no match from your input to the keys in dict. If you are going to use <dict>. get(), you will get no Key error. You get None as a retur if there is no match. print(playfair.get(new_inp)) But you can customize what kind of feedback you want to get: print(playfair.get(new_inp,'key not found')) In this case 'key not found' will be retured if no match from input to keys in dict will be found.
Since there is only one input you can only input one letter
You can take the input in the form of a list and then apply the dictionary substitution in each letter using for loop.... x = list(input()) for i in range(len(x)): print(dic[x[i]]) Try this if you want them in just one line then use function generator(using yield).... And then use join function... Make a key of ' ' space also so that your code can even take a sentence