question 73 Dictionaries & Sets · easy
Language code from a typed name
Runtime Films stores languages as code → name ("de": "German"). A search box needs the opposite: someone types a language name, in any capitals and with stray spaces, and the site needs its code. Build a name → code dictionary from languages, then print the code for typed, or no language called <name> with the cleaned name.
Inputs
languages, a dictionary from code to name; typed, the text from the search boxMatchingignore capitals and spaces at the ends of
typed; names in languages match whatever their capitalsShared namesif two codes have the same name, the code that comes first in
languages winsPrintsthe code, or
no language called <cleaned typed text>Examples
" german" → de; "KOREAN" → koExpected output1 line
- 1de