Skip to content

Instantly share code, notes, and snippets.

@duonghau
Created July 31, 2015 03:32
Show Gist options
  • Save duonghau/a7e169dc2ca3292dd190 to your computer and use it in GitHub Desktop.
Save duonghau/a7e169dc2ca3292dd190 to your computer and use it in GitHub Desktop.
reversestring
#author Duong Tien Hau
#Function: Enter a string and the program will reverse it and print it out.
def reversestring(string):
if len(string)==1: return string
stringreverce=''
for i in range(len(string)):
stringreverce+=string[len(string)-(i+1)]
return stringreverce
def main():
string=input("Input a string:")
print(reversestring(string))
if __name__=="__main__": main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment