want to store elements in array or list using python
<p>I am learning python. I want to store one by one element in array or list.
this is my code.      </p>

<pre><code>for u in durl:
      p2 = requests.get(u)
      tree = html.fromstring(p2.content)
      dcode.append = tree.xpath(ecode)
      print(dcode)
</code></pre>

<p>in dcode variable the elements are overriding not appending.
i want to insert it one by one.
please help me.  </p>

<p>You can do it this way, it appends new value to the list and it makes more sense...sort of data structure</p>

<pre><code>def main(decode=[]):
  for u in durl:
      p2 = requests.get(u)
      tree = html.fromstring(p2.content)
      dcode.append(tree.xpath(ecode))
      print(dcode)
</code></pre>

python arrays list python-2.7