Skip to content

Instantly share code, notes, and snippets.

@gkfarwaha
Created October 15, 2020 06:40
Show Gist options
  • Save gkfarwaha/1a9aac0717bf82819fa850a1ae2b17a2 to your computer and use it in GitHub Desktop.
Save gkfarwaha/1a9aac0717bf82819fa850a1ae2b17a2 to your computer and use it in GitHub Desktop.
reversing the string
# GET YOUR LINE PRINTED BACKWARDS
print("Enter the string you want to print backward")
str1 = input()
print("String entered by you as follows\n", str1)
print("String entered by you in upper case as follows\n", str1.upper())
print("String entered by you in lower as follows\n", str1.lower())
x = int(len(str1))
print("Length of the string: ", x)
i = x
print(type(i))
revstr = ""
while i > 0:
i -= 1
revstr += str1[i]
print(revstr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment