Skip to content

Instantly share code, notes, and snippets.

@kijart
Created May 22, 2018 10:40
Show Gist options
  • Save kijart/770ba85a2923bc96f2286c2b4f6707be to your computer and use it in GitHub Desktop.
Save kijart/770ba85a2923bc96f2286c2b4f6707be to your computer and use it in GitHub Desktop.
Hash map tests in Python
country_languages = {
'AT': ['de-AT', 'en', 'fr'],
'CH': ['de-CH', 'en', 'fr'],
'DE': ['de-DE', 'en', 'fr'],
}
languages_hash = {}
for country_code, language_codes in country_languages.items():
for language_code in language_codes:
locale = language_code.split('-')[0]
if not country_code in languages_hash:
languages_hash[country_code] = {}
if not language_code in languages_hash[country_code]:
languages_hash[country_code][locale] = {}
languages_hash[country_code][locale] = {}
print(language_hash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment