import os def printReverse(string): # Get length of string stringLength = len(string) # Variable holding the new reversed string newString = "" # Position of first letter is considered 0 in string # Set i to position of last letter in string i = stringLength - 1 # Iterate the string backwards (count backwards from length of string down to zero) while i >= 0: # Add character of position i to new reversed string newString = newString + string[i] # Decrease counter by 1 i -= 1 print(newString) # Clear screen os.system("clear") # Mac or Linux #os.system("cls") # Windows userInput = input("Input a string: ") # Call printReverse function printReverse(userInput)