# Here are the lines of a text file printed out. John Locke David Hume Edmund Burke >>> #====== >>> #The lines on the files are stored with \n >>> # Often you don't want to work with the \n >>> # you may want to get rid of the \n before >>> # working with the line in your program >>> # >>> # string method >>> # rstrip - strip from the right >>> # strip is the same >>> "hi".lstrip('h') 'i' >>> x = "he \t there \t sam \t \t \n" >>> x 'he \t there \t sam \t \t \n' >>> print(x) he there sam >>> #'white space' spaces, tabs, and newlines >>> x.rstrip() 'he \t there \t sam' >>> x.strip() 'he \t there \t sam' >>> y = 'hello jjj' >>> y.strip('j') 'hello ' >>> z = "aaa bbb ccc ddd" >>> z.strip('d') 'aaa bbb ccc ' >>> z.strip(' d') 'aaa bbb ccc' >>> z.strip(' dc') 'aaa bbb'