I have saved a list of ticker symbols into a text file as follows:
MMM
ABT
ABBV
ANF
....
Then I use readlines to put the symbols into a Python list:
stocks = open(textfile).readlines()
However, when I look at the list in it contains Windows end-of-line delimiter which I do not want:
list: ['MMM\r\n', 'ABT\r\n', 'ABBV\r\n', 'ANF\r\n', 'ACE\r\n', 'ACN\r\n', 'ACT\r\n', 'ADBE\r\n', 'ADT\r\n', 'AMD\r\n', 'AES\r\n', .....
Can someone suggest the easiest way to remove these unwanted characters?