title: A double preceding function with bug
body: <p>It is a homework question that I am stuck on:</p>
  
  <p>Your classmate claims to have written a function that replaces each value in a list with twice the preceding value (and the first value with 0). For example, if the list [1, 3, 7, 11] is passed as a parameter, the function is supposed to return [0, 2, 6, 14] -- Note: 22 is not part of the output. Here's the code:</p>
  
  <pre><code>def double_preceding(values): 
      if (values != []): 
          temp = values[0] 
      values[0] = 0
      for i in range(1, len(values)): 
          values[i] = 2 * temp 
          temp = values[i]
  </code></pre>
  
  <p>Analyse this function and rewrite it so that it works as intended.</p>
  
  <p>I couldn't even follow what the code was doing, can someone explain to me please</p>