Created
July 31, 2015 03:32
-
-
Save duonghau/a7e169dc2ca3292dd190 to your computer and use it in GitHub Desktop.
reversestring
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
#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