def get_doubled_letter_countries()
This function creates and returns a tuple of all the countries that have consecutive repeated letters. When called it returns that tuple, in alphabetical order by the doubled letters:
('morocco', 'greece', 'marshall islands', 'seychelles', 'cameroon', 'philippines', 'andorra', 'sierra leone', 'guinea-bissau', 'russia', 'saint kitts and nevis')
Notice they are in alphabetical order by the doubled letters: c, e, l, l, o, p, r, r, s, s, t
This is my code:
def get_doubled_letter_countries(double_letter_list):
""""
This function creates and returns a tuple of all the countries that have consecutive repeated letters.
When called it returns that tuple, in alphabetical order by the doubled letters:
"""
double_letter = re.compile(r'.*(.)\1.*', re.IGNORECASE)
double_letter_list = []
for countrie in countries:
for word in countrie.split(" "):
match = double_letter.match(word)
if match:
double_letter_list.sort()
double_letter_list.append(match.group())
print(tuple(double_letter_list))
It prints this: ('Andorra', 'Cameroon', 'Greece', 'Guinea-Bissau', 'Kitts', 'Marshall', 'Morocco', 'Philippines', 'Russia', 'Seychelles', 'Sierra')
I need it to print this: ('morocco', 'greece', 'marshall islands', 'seychelles', 'cameroon', 'philippines', 'andorra', 'sierra leone', 'guinea-bissau', 'russia', 'saint kitts and nevis')