diff --git a/kotlin-website.py b/kotlin-website.py index a7ae0a012a9..79c02d2c132 100644 --- a/kotlin-website.py +++ b/kotlin-website.py @@ -129,9 +129,13 @@ def get_nav(): return nav def get_countries_size(): - def match_string(string): - return re.search(r'\((.*?)\)', string.get("location")).group(1) - matches = set(map(match_string, site_data['universities'])) + def match_string(entry): + location = entry.get("location", "") + # Extract the last part as the country code + return location.split(",")[-1].strip() + + # Extract unique countries, ignoring any None results + matches = set(filter(None, map(match_string, site_data['universities']))) return len(matches)