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
Post a Comment