• Bird Language Regex

Question related to mission Bird Language

 

I was able to figure this out with learning some regex.

It works except for the last assertion and I can't figure it out. VOWELS = "aeiouy"

import re

def translate(phrase):

test = re.sub(r'([bcdfghjklmnpqrstvwxz])([aeiouy])', r'\1', phrase)

new_phrase = re.sub(r'(aa|ii|oo|ee|uu|yy)', '', test)

return new_phrase



assert translate("sooooso aaaaaaaaa") == "sos aaa", "Mayday, mayday"

This last test: I return 'sos a'. I can't figure how to do this and remove the other ooo's etc.

Thanks for any help!!!

5