title: How to get the added values from the start of a numerical list up till a certain point determined by an input?
body: <p>I have a list that I want to be able to reference in a way where I can get the added values from the start of the list to a certain position, determined by an input.</p>
  <p>here is something i tried but it doesn't work:</p>
  <pre><code>leap_year = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  value = 0
  months = int(input())
  for x in leap_year:
      while x &lt; leap_year[months - 1]:
          value = value + x
  print(value)
  </code></pre>
  <p>A possible output could look like this:</p>
  <pre><code>months = 5 #by an input
  value = 152 #by adding the first 5 terms in the sequence 
  </code></pre>