how to make a nested list
Prasad, Ramit
ramit.prasad at jpmorgan.com
Thu Sep 15 13:09:07 EDT 2011
>>> B = 3 * [ [ None, None ]]
That makes a list of the exact same list object: [ a, a, a ] where a = [ None, None ].
Instead I would do something like (untested python2.x):
B = [ [ None, None ] for x in xrange(3) ]
Ramit
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
More information about the Python-list
mailing list