Python’s String “replace” method returns a copy of the string in which the occurrences of the old substring are replaced with the new substring. You can optionally restrict the number of replacements to a max amount by adding another number argument to the method call; for example “str.replace(old, new, max)”.
Note that I use the end-of-input indicator for Windows, Ctrl-Z, to signify the end of input from the command-line.