Created
November 7, 2017 08:52
-
-
Save tadone/a8f0e94f3238eb1c075983accf172208 to your computer and use it in GitHub Desktop.
[Reverse String] Reverse given string using string slicing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is extended slice syntax. It works by doing [begin:end:step] - by leaving begin and end off and specifying a step of -1, it reverses a string. | |
>>> 'hello world'[::-1] | |
'dlrow olleh' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment