How do I Change one character in a string in python?
name = 'Don Danucci' index = 4 print(name[:index] + 'F' + name[index + 1:])
Strings in python are immutable. A single character at index i cannot be changed. This example takes the first part of the string, adds the desired character and adds the rest of the string.
Link to documentation or other source
07 Jun 2019
Author: Loek van den Ouweland
Would you recommend this example to your colleagues?