I want to know how to reverse a string in python without creating a new one.
I can't seem to get it.
I want to know how to reverse a string in python without creating a new one.
I can't seem to get it.
Python strings are immutable, which means you can't really change it. There's no way you could reverse it in-place.
Obviously, you could reassign the same variable to it, but this is not an in-place change as you asked for:
str = 'reverse'
str = str[::-1]