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

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -