The solution to problem on slides 4-5: (HW)
(also found on slide)
import re
def subfunc(match):
global i, x
m = match.group(0)
if m == 'AN':
return 'UN'
elif m == 'AU':
return 'OO'
elif m == 'A':
if match.start() == len(x)-2:
return 'A'
return 'E'
elif m == 'OW':
return 'OO'
elif m == 'O':
return 'U'
elif m == 'I':
if match.start() == 1:
return 'I'
if i == False:
i = True
return 'EE'
else:
return 'I'
elif m == 'EN\n':
return 'EE\n'
elif m == 'E\n':
return 'E-A\n'
elif m == '\nE':
return '\nI'
elif m == 'U':
return 'OO'
for _ in range(5):
i = False
x = '\n'+input()+'\n'
print(re.sub('(AN|AU|A|OW|O|I|EN\n|E\n|\nE|U)', subfunc, x)[1:-1])