Using replace() method in python by index

The problem is that .replace(old, new) returns a copy of the string in which the occurrences of old have been replaced with new.

Instead, you can swap the character at index i using:

new_str = old_str[:i] + "b" + old_str[i+1:]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)