Skip to content

Instantly share code, notes, and snippets.

@sshehrozali
Created November 9, 2020 18:53
Show Gist options
  • Select an option

  • Save sshehrozali/cd18eb6dc442044d561e622133fc3ecf to your computer and use it in GitHub Desktop.

Select an option

Save sshehrozali/cd18eb6dc442044d561e622133fc3ecf to your computer and use it in GitHub Desktop.
Python code to reverse a string
# 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