Created
November 9, 2020 18:53
-
-
Save sshehrozali/cd18eb6dc442044d561e622133fc3ecf to your computer and use it in GitHub Desktop.
Python code to reverse a 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
| # Prompt user to enter any name | |
| name = input("Please enter any name: ") | |
| # Print name in reverse order | |
| print("Reversed: ", end="") | |
| # Iterate till last char of string, print reversely | |
| for i in range(1, len(name) + 1): | |
| print(name[-i] ,end="") | |
| # End | |
| print("\nFinished") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment