lines = [l.split() for l in inpf.readlines() if l.strip()]
In the above statement, what does l.strip() do?
lines = [l.split() for l in inpf.readlines()].
Will the above statement will not suffice?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
strip()removes any leading/trailing whitespace. so it will skip any lines that consist of nothing but whitespace or are empty.On a side-note, there is no need to use
.readlines()– you can iterate over the lines instead and thus avoid creating a second list which is thrown away right after the list comprehension finished: