fileinput = open('tweets.txt', 'r')
for line in fileinput:
lines = line.lower()
from this how can I take the whole lines and not only the last?
fileinput = open('tweets.txt', 'r')
for line in fileinput:
lines = line.lower()
from this how can I take the whole lines and not only the last?
The following will give you a list:
fileinput = open('tweets.txt', 'r')
lines = [line.lower() for line in fileinput]
If this is not what you're looking for, please clarify your requirements.
The problem is that you are using the assignment operator =
.
You need to change this to a +=
but you will lose the new line character \n
.
I would suggest opening a list like this:
fileinput = open('tweets.txt', 'r')
lines = []
for line in fileinput:
lines.append(line.lower())
Then you will have all lines in a list.
Regards Joe
If you want to convert all the lines:
fileinput = open("tweets.txt", "r")
lowered = [l.lower() for l in fileinput]