Reverse a string in Python -


there no built in reverse function in python's str object. best way of implementing this?

if supplying concise answer, please elaborate on it's efficiency. str converted different object, etc.

how about:

>>> 'hello world'[::-1] 'dlrow olleh' 

this extended slice syntax. works doing [begin:end:step] - leaving begin , end off , specifying step of -1, reverses string.


Comments

Popular posts from this blog

service - Android MediaPlayer calls onCompletion before it already finished -

javascript - Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn? -

javascript - Create a stacked percentage column -