runtime
73 / 500
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.

Inputslanguages, a dictionary from code to name; typed, the text from the search box
Matchingignore capitals and spaces at the ends of typed; names in languages match whatever their capitals
Shared namesif two codes have the same name, the code that comes first in languages wins
Printsthe code, or no language called <cleaned typed text>
Examples" german" → de; "KOREAN" → ko
Expected output1 line
  1. 1de

Loading your progress…

Language code from a typed name — Python practice · Runtime