Python strings are immutable, you change them by making a copy. The easiest way to do what you want is probably. text = "Z" + text[1:]The text[1:] return the string in text from position 1 to the end, positions count from 0 so '1' is the second character. You can use the same string slicing technique for any part of the stringtext = text[:1] + "Z" + text[2:]