0

Is there a way I can efficiently read every two lines from input? So, in

data = fileinput.input()  
# Now, instead of doing
for line in data:
    pass
# I need to do
for (every block of two lines in data):
    pass

I am using Python 2.

  • Btw, I'm new to Stack Overflow, so I apologize if I somehow did something wrong, like leave out information. (I did check for similar questions beforehand.) – Benjamin Levy Feb 01 '16 at 03:10
  • What are you actually trying to do? (i.e. end goal) – rnevius Feb 01 '16 at 03:10
  • @rnevius For every block of two lines, the first line (in the block) is an integer expressing how many elements there are in the list in the second line of the block. I need to store the integer value in the first line, and the list in the second line, in two different variables. I do not know how many of these blocks there are. – Benjamin Levy Feb 01 '16 at 03:16

0 Answers0