Reverse the string (IN PLACE) in python

Reverse the string (IN PLACE) in python

Python strings are immutable, which means you cant really change it. Theres 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]

Reverse the string (IN PLACE) in python

Leave a Reply

Your email address will not be published. Required fields are marked *