def replace_at_index(string, index):
print (string.replace(string[index], "-", 1))
That's my current code for replacing a character with a given index.
- string "House" with Index 4 produces "Hous-"
- string "Housee" with Index 5 produces "Hous-e"
- string "Houseed" with Index 6 produces "Housee-"
- string "Houseed" with Index 5 produces "Hous-ed"
Not sure why it's doing this. The result I'm wanting is for it to replace the given Index, which in the case of "Housee" Index 5 would be "House-"