Something like this?
def decode (line):
return ' '.join (token [:-3]
if token.endswith ('WAY')
else (lambda a, b: b [:-3] + a) (*token.split ('X') )
for token in line.split () )
Sample:
>>> decode ('elloXHWEY orldXwWEY isXthWEY isWAY eatXgrWEY')
'Hello world this is great'
Nota bene: Might fail with words conaining ‘X’. But it should be something to get you started.
2
solved Convert piglatin to english?