Last active
February 16, 2019 07:22
-
-
Save pysoftware/a8470175187056749c15e6cf61410cde to your computer and use it in GitHub Desktop.
Reverse string
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
# Reverse a string/ Переворот строки | |
a = 'Hello world!' | |
# 1 way | |
a = a[::-1]# Result: !dlrow olleH | |
# 2 way | |
reversed_string = '' | |
for i in a: | |
reversed_string += i# Result: !dlrow olleH | |
# 3 way | |
a.reverse() #Result: !dlrow olleH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment