Skip to content

Instantly share code, notes, and snippets.

@pysoftware
Last active February 16, 2019 07:22
Show Gist options
  • Save pysoftware/a8470175187056749c15e6cf61410cde to your computer and use it in GitHub Desktop.
Save pysoftware/a8470175187056749c15e6cf61410cde to your computer and use it in GitHub Desktop.
Reverse string
# 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