How can I generate a list with regex in python for countries with 4 or 5 letters?
names = ['Azerbaijan', 'Zimbabwe', 'Cuba', 'Cambodia', 'Somalia','Mali', 'Belarus', "Côte d'Ivoire", 'Venezuela', 'Syria', 'Kazakhstan', 'Austria', 'Malawi', 'Romania', 'Congo (Brazzaville)']
I was trying to do this but it returns an empty list:
import re
n = [w for w in names if re.findall(r'[A-Z]{4,6},', str(names))]
print(n)
Output:
[]
It is an exercise that's why I can only do it with the module re. Any help will be appreciate.