Given the specifics of a dictionary (see sample dictionary below) and based on user input, I need to match the per-letter input and the keys then output the values.
I was able to get the output that I want, except that when input includes a special character, it will not display as output (only letters).
Here is the sample dictionary:
dict1 = {'a':'q', 'b':'w', 'c':'e', 'd':'r', 'e':'t', 'f':'y', 'g':'u' ...}
I tried with the codes below:
sentence = input("Enter a sentence:")
result = ''.join([dict1.get(x, ' ') for x in sentence])
print(result)
If I input: abc, de. f-g
The output: qwe rt yu
I would like to have this output instead: qwe, rt. y-q
Is it possible?
~ EDIT: found my mistake in my code (overlooked something). Was able to fix it. Thanks.