What is the cleanest way to initialize dynamic list in Python?
<p>This is a question regarding best coding practices. Suppose I have to populate a list of unknown length; usually I just initialize the list with <code>myList = []</code>, but I feel like this is a poor way of doing this. I often end up with chunks of code that look like this:</p>

<pre><code>list1 = []
list2 = []
list3 = []

for a,b,c in zip(x,y,z):
    list1.append(a)
    list2.append(b)
    list3.append(c)
</code></pre>

<p>I realize in the example you can initialize this lists to the correct length, in fact you can just use <code>x,y,z</code> as they are. My question is regarding a situation in which you don't necessarily know the length of the lists. In my opinion, having to use three lines to initialize this lists is clunky; what do you guys thing? Thanks for any input!</p>

<p>No need for anything clever:</p>

<pre><code>list1 = list(x)
list2 = list(y)
list3 = list(z)
</code></pre>

python