I am making a program where a letter of a piece of text is replaced by its corresponding number(like a is replaced by 1, b is replaced by 5 and so on). If the letter is uppercase, it is first converted into lowercase.
Here is an example
8 5 12 12 15 23 15 18 12 4
HERE IS THE CODE
The output is fine when all the letters are lowercase. But it comes to uppercase letters, the console shows an error.
Here is an error shown by the console when the input is
Traceback (most recent call last): File "C:/Users/admin/Desktop/Code/untitled/sample.,py.py", line 15, in <module> print(alphabet_position('Hello World')) File "C:/Users/admin/Desktop/Code/untitled/sample.,py.py", line 12, in alphabet_position output += " "+ str ( code[N] ) KeyError: 'H' Process finished with exit code 1
As you see here, I got a
KeyError. So, I must have done some something wrong in the dictionary
codeand maybe somewhere else also. Well, I am not able to find the error so I would like to get help from the community
Every suggestion will be appreciated