-1
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) in report, starting with the first line.
    """
vaultah
  • 44,105
  • 12
  • 114
  • 143
  • 4
    Have you tried solving that yourself? – vaultah Mar 04 '16 at 19:41
  • 2
    Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation. [Minimal, complete, verifiable example](http://stackoverflow.com/help/mcve) applies here. We cannot effectively help you until you post your code and accurately describe the problem. StackOverflow is not a coding or tutorial service. – Prune Mar 04 '16 at 19:44
  • Try writing something you hope will work, then (if it doesn't), try asking why – holdenweb Mar 04 '16 at 20:04
  • I tried since last night... but okay for the future reference, I'll post my progress as well. Thank you. – Chang Dae Hyun Mar 04 '16 at 20:51

1 Answers1

0

If I recall correctly, you would do it like this:

def every_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!

Wer900
  • 12
  • 4