Run-error in my code

Sir/Mam
My code gives required output but when it comes to submitting code, it comes out to be run-error. Kindly help.

Also what should be done when the given query string is not present in dictionary??