python: how to create list of/iterate through multiple instances of a variable
<p>I am working with the pymarc library. My question is, how to I deal with multiple instances of a variable, either building a list, or otherwise iterating through them? </p>

<p>A MARC field can be accessed by adding the field number to the <code>record</code> variable. For instance, I have three instances of an 856 field in one record, which can be accessed as <code>record['856']</code>. But only the first instance is passed.</p>

<p>assigning a variable <code>record['856'][0]</code> or <code>record['856'][1]</code> etc, doesn't work.</p>

<p>I have tried creating a list, which is shown below, but that didn't work</p>

<pre><code>from pymarc import MARCReader

with open('file.mrc', 'rb') as fh:
    reader = MARCReader(fh)
    for record in reader: 
            """get all 856 fields  -- delete unwanted 856 fields
            =856  40$uhttp://url1.org
            =856  40$uhttp://url2.org
            =856  40$uhttp://url3.org
            """
                eight56to956s = []
                eight56to956 = record['856']
                eight56to956s.append(eight56to956)
                print eight56to956s
</code></pre>

<p>I know how I would do this in php, but I'm not getting my head around python syntax to even search the web for the right thing. </p>