Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 2
How to reverse a string with preserving the spaces using python
3 Respostas
+ 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!