Thanks! I'll have a go at understanding this. I've not come across 'map' before.
It would also be good if somebody could help me understand what's wrong with my own code (for learning purposes), and also because I may wish to introduce more ways of editing such as deleting certain letters and thus needing to keep track of changes as it goes to ensure replacements still occur in the right place.