Remove '\n' From Each String Stored In A Python List
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'
Solution 1:
Try something like this:
with open("myfile.txt") as f:
d = map(str.rstrip, f.readlines())
print d
For your input above this will output:
['Java Basic', 'Core Java', 'C++', 'Python']
Post a Comment for "Remove '\n' From Each String Stored In A Python List"