How Would I Do This In A File?
def every_second_line(report): ''' (Open File for reading) -> list of str Return a list containing every second line (with leading and trailing whitespace removed)
Solution 1:
If I recall correctly, you would do it like this:
defevery_second_line(report_location):
""" This code will return every second line with trailing whitespace stripped."""
report = open(report_location, rb+)
second_lines = [a.strip() for a in report.readlines()[1::2]]
return second_lines
I don't have Python with me at the moment, but this should work. Good luck!
Post a Comment for "How Would I Do This In A File?"