Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def to_code_3(country_name, fuzzy=False):
"""Given a human name for a country, return a three letter code.
Arguments:
``fuzzy``: Try fuzzy matching based on Levenshtein distance.
"""
code = to_code(country_name, fuzzy=fuzzy)
if code and len(code) > 2:
return code
elif code is None:
return code
else:
return mappings[code]