On Wed, 8 Jun 2022 at 19:13, Dave <d...@looktowindward.com> wrote: > > Hi, > > Thanks for this! > > So, is there a copy function/method that returns a MutableString like in > objective-C? I’ve solved this problems before in a number of languages like > Objective-C and AppleScript. > > Basically there is a set of common characters that need “normalizing” and I > have a method that replaces them in a string, so: > > myString = [myString normalizeCharacters]; > > Would return a new string with all the “common” replacements applied. > > Since the following gives an error : > > myString = 'Hello' > myNewstring = myString.replace(myString,'e','a’) > > TypeError: 'str' object cannot be interpreted as an integer > > I can’t see of a way to do this in Python? >
Not sure why you're passing the string as an argument as well as using it as the object you're calling a method on. All you should need to do is: myString.replace('e', 'a') ChrisA -- https://mail.python.org/mailman/listinfo/python-list