# File: strstrip.py # Changes case of characters in a string # # # Matt Bishop, MHI 289I, Winter 2019 # while True: # read in a string; quit on EOF try: instr = input("Enter a string: ") except EOFError: break except: print("Unknown error; EOF to end") continue # # put quotes around the string to show its boundaries when it is printed # prstr = '"' + instr + '"' # # now strip the white space # transstr = '"' + instr.lstrip() + '"' print("Deleting the leading white space from", prstr, "gives", transstr) transstr = '"' + instr.rstrip() + '"' print("Deleting the trailing white space from", prstr, "gives", transstr) transstr = '"' + instr.strip() + '"' print("Deleting the leading and trailing white space from", prstr, "gives", transstr)