I have query.I am new to Python
Lets say I have a file in.txt
. Inside this file I have some name like below.
Sunday
Monday
Tuesday
.
.
I want to put them into a list, I am doing:
#!/usr/bin/python3
with open("in.txt") as f:
lines = f.readlines()
lines = [l for l in lines]
print (lines);
The output is:
['Sunday\n', 'Monday\n', 'Tuesday\n']
I want to print it like:
['Sunday', 'Monday', 'Tuesday']
how will I remove \n
Any suggestion will great help, I tried rstrip()
it didn't work.