title: Modifying List elements in a loop
body: <p>Is it possible to update/modify the list elements/items in a loop. Here I have to modify items of <code>t</code> </p>
  
  <pre><code>n_wk=[1,2,3,2,3,4,2,3]
  t=['a','a','a','a','a','a','a','a']
  
  for i in range(len(n_wk)):
      if i==0:
          continue
      if n_wk[i]&lt;n_wk[i-1]:
          if t[i]=='a':
              t[i]='b'
          elif t[i]=='b':
              t[i]='c'
      if n_wk[i]&gt;n_wk[i-1]:
         t[i]=t[i-1]
  </code></pre>
  
  <p>I was expecting output <code>t = ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c']</code>. But, the output is coming out to be <code>t=['a', 'a', 'a', 'b', 'b', 'b', 'b', 'b']</code>. Seems like <code>list t</code> is not getting updated in the loop. </p>
  
  <p>Can we not update item/elements of the list in a loop?</p>