I have a python list in which look like this:
my_list = ['OFAC\n', 'Social Media Analytics\n', 'Teaching Skills\n', 'Territory...\n', 'Active Directory...\n', 'Business Research\n', 'Call Center...\n', 'Treatment of depression\n', 'VB\n', 'CAN\n', 'Client Interfacing...\n', 'Consolidated Financial...\n']
How can i remove the \n from the end of each element and why is strip not working ?.
I tried line.strip('\n')
and line.replace('\n','')
but it is not affecting anything.
The text file from which the list is made looks like this:
Java Basic
Core Java
C++
Python
...
Code for putting the textfile into the list is:
with open("myfile.txt") as f:for line in f:st_line = line.strip('\n')d.append(st_line)