title: Access values from next line within for-loop to continue and break?
body: <p>In the given data set I need to multiply values from different blocks with each other.</p>
  
  <p><strong>I want to access data from next line within for loop and then build the list and create a product if the block value matches</strong> but the examples I have looked so far isn't quite helping. Actually, this data is just a part of the big data and I need some explanation on any provided solution on how/why is it working.</p>
  
  <p><code>So,for X(set) I have to multiply: 0.25*0.1*0.83 (since they belong to same block</code></p>
  
  <pre><code>block   X_set
  2480    0.25
  2480    0.1
  2480    0.083
  2651    0.43
  2651    0.11
  2651    0.23
  </code></pre>
  
  <p>My code is as follows:</p>
  
  <pre><code>test_q = open("test_question.txt", "r+")
  header = test_q.readline()
  data_q = test_q.read().rstrip("\n")
  
  product=1.0
  value_list = []
  
  row = data_q.split("\n")
  
  for line in row:
      block = line.split("\t")
      X_list = block[1].split()
      X_value = float(block[1])
      value_list = value_list + X_list
      product = product*X_value
  
  print(value_list)
  print(product)
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>['0.25', '0.1', '0.083', '0.43', '0.11', '0.23']
  2.2573925000000003e-05
  </code></pre>
  
  <p>But, in the print I want</p>
  
  <pre><code>['0.25', '0.1', '0.083']
  0.0002075
  
  ['0.43', '0.11', '0.23']
  0.010879
  </code></pre>
  
  <p>So, I want to access the index value from the next line so the for-loop can continue or break. </p>
  
  <p>I have tried using to access the block value from next line:</p>
  
  <pre><code>    for i in range(0, len(row)-1):
      next_line = row[i+1]
  </code></pre>
  
  <p>How, can I improve this code?</p>
  
  <p><strong>So, how to inject the break and continue function within this for-loop?</strong></p>
  
  <ul>
  <li><p>I don't want to use a fixed value for blocks since this is a long file and the block value will change.</p></li>
  <li><p>Also, the row with same block values may not be next to each other.</p></li>
  <li><p>Also, i don't need solution on pandas since this is just a part of big file which is exclusive mined using for-if-else loop.</p></li>
  </ul>
  
  <p>Thanks much in advance !</p>