Appending to a list from a for loop (to read a text file)
<p>How do I append to an undetermined list from a for loop?
The purpose is to first slice each line by '-'. Then I would like to append these slices to an array without a determined size. I have the following code, and am loosing hair because of how simple this seems! </p>

<p>Each line in the text file looks like the following: 
2014-06-13,42.7,-73.8,27</p>

<p>program so far:</p>

<pre><code>f = open('Lightning.txt')

lightning =list()

for templine in f:

    if not templine.startswith('2014'): continue

    templine = templine.rstrip('-')

    line = templine.split()

    print line[2]
</code></pre>

<p>Thank you community,</p>

<p>Do this: <code>for templine in f.read():</code>  
You forgot the read() methid</p>

python string list append slice