+ 2
How to reverse a string with preserving the spaces using python
4 Respuestas
+ 1
Just:
your_string = your_string[::-1]
(Or, if it's the *position* of the spaces which you want to preserve, what Błack Jesus❕ said.)
- 1
Can you write a python program and give?
- 1
A simple way to do it:
new_string = ''.join(list(old_string)[::-1])
I hope that is good enough for you!