String is immutable so its cannot be modified but there some way out.
with python builtin method join and list helping
1. List and Join (Conversion) data type
Code:
l = list(string)
string = ''.join(l)
return string
This method is more optimal than the slicing method
>>> string = string[:5] + "k" + string[6:]
>>> print string
abrackdabrahere this not optimal for large amount of modification frequent cause here we re-creating
string again and method 1 we assigning variable again with conversion and modification
we can use in-place algorithms with patterns or linear search but maybe that work
Put Your Thought or Query Here