Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103463
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Andrew Farrell <amfarrell@mit.edu> |
| Newsgroups | comp.lang.python |
| Subject | Re: Nested List question |
| Date | Wed, 24 Feb 2016 15:11:35 -0600 |
| Lines | 48 |
| Message-ID | <mailman.106.1456348637.20994.python-list@python.org> (permalink) |
| References | <4AD2810BE3B346399F777EDEAB079BDA@OPTIPLEX990> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de 8cHPAMhkYhWEkFEMNc7nxA8+rT3XCRi2qGPYMfJwk24w== |
| Return-Path | <amfarrell@mit.edu> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'elements.': 0.05; 'subject:question': 0.08; 'cc:addr:python-list': 0.09; 'donor': 0.09; 'received:209.85.218': 0.10; 'python.': 0.11; 'wed,': 0.15; '2016': 0.16; '24,': 0.16; 'innermost': 0.16; 'list"': 0.16; 'nest': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'scientist': 0.16; 'wrote:': 0.16; 'element': 0.18; 'nested': 0.18; 'all,': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'feb': 0.23; 'chapter': 0.23; 'tried': 0.24; 'words': 0.24; 'header:In-Reply-To:1': 0.24; 'figure': 0.27; 'message- id:@mail.gmail.com': 0.27; 'looks': 0.29; 'that.': 0.30; 'url:mailman': 0.30; 'url:python': 0.33; 'extract': 0.33; 'subject:List': 0.33; 'url:listinfo': 0.34; 'correctly': 0.34; 'lists': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'park': 0.35; 'url:org': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'list.': 0.37; 'received:209': 0.38; 'several': 0.38; 'goes': 0.39; 'url:mail': 0.40; '1st': 0.83; 'avenue.': 0.84; 'outermost': 0.84; 'broadway': 0.91 |
| X-AuditID | 1209190f-077ff7000000091f-a0-56ce1ca7eb53 |
| X-Gm-Message-State | AG10YOR6O4EfGIi+kYyOBZ2Y0ful5Pq2H7wxojjB6PEmA/TTGdkzeK4JZV/QMgu2af9BeLfIRpNErfnmm0BFyw== |
| X-Received | by 10.202.210.195 with SMTP id j186mr33965329oig.56.1456348325076; Wed, 24 Feb 2016 13:12:05 -0800 (PST) |
| In-Reply-To | <4AD2810BE3B346399F777EDEAB079BDA@OPTIPLEX990> |
| X-Gmail-Original-Message-ID | <CA+y5TLYCzENBAbHr9cn0z2rm+PqKAYY-TwWs4y3MK2FwGk9v=g@mail.gmail.com> |
| X-Brightmail-Tracker | H4sIAAAAAAAAA+NgFtrIKsWRmVeSWpSXmKPExsUixCmqrLtc5lyYwd9+GYsjrddYHRg9Xsx/ wxbAGMVlk5Kak1mWWqRvl8CV8bPlN0vBP92Kv1/XMTcwzlfvYuTkkBAwkVizvom5i5GLQ0ig jUli7voNLBDOOUaJee132CGcB0wSv35fYoJwJjBK3LzwgQ2iP0eitW09C4RdJvHz/g8wm1dA UOLkzCdgtpCAp8TdF/NYQWxOAWuJLwfmM0LErSQe/j7HBGKzCWhI3Pr5ECzOIqAqseP8HEaI mYkSV+bcZIOYGSDxf/YXsLiwgKLE+ze3wWaKCEhJdNzvAqthBpoz/d53KNtL4l3PL/YJjMKz kJw0C0lqFiMHkK0usX6eEERYTeL2tqvsELa2xLKFr5kXMLKuYpRNya3SzU3MzClOTdYtTk7M y0st0jXRy80s0UtNKd3ECI4HSf4djN8OKh1iFOBgVOLhZfh5NkyINbGsuDL3EKMkB5OSKG8l z7kwIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8HVJAOd6UxMqq1KJ8mJQ0B4uSOG/MzaNhQgLp iSWp2ampBalFMFkZDg4lCd7F0kCNgkWp6akVaZk5JQhpJg5OkOE8QMPvgdTwFhck5hZnpkPk TzEac2z5fW0tE8e2qffWMgmx5OXnpUqJ834CKRUAKc0ozYObBkppF0Nvab1iFAd6Tpg3DaSK B5gO4ea9AlrFBLTq9rZTIKtKEhFSUg2MJc/cN9+oW6na8fHAC3OOVu8/rGvNPldbaHBvnSX9 5fq7CuHey2t2+h1bN59xQuxmw+sGCSadtdJH/686Wlawd5LVevH6uU3B26SjShe2fmypmaed 9/MEi47PJ7YtvX5n/1e5a61vyDIIyvz7WftU1961+zpvL0u4sy7v3Kf8snW9rztnHT15TIml OCPRUIu5qDgRAFGsVPVEAwAA |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21rc2 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:103463 |
Show key headers only | View raw
you can indeed have a nested list. One way you could do that looks like
donor = [
'George',
'Soros',
[ #<- 2nd element of outermost list
'99 First Street',
[ #<- 1st element of middling list
'33 Broadway Avenue',
'Apt 303', #<- 1st element of innermost list
],
'1 Park Avenue'
],
'New York', 'NY',
]
Then, to extract "Apt 303", you could do
donor[2][1][1]
A better explaination of nested lists can be found if you ctrl-f search
for "nested list" on this chapter
<http://www.greenteapress.com/thinkpython/thinkCSpy/html/chap08.html> of
the book How to Think Like a Computer Scientist with python.
On Wed, Feb 24, 2016 at 2:59 PM, <grsmith@atlanticbb.net> wrote:
> All,
>
> Can you have a phython list like:
> ['George',
> 'Soros',
> ['99 First Street',
> '33 Broadway Avenue', ['Apt 303'],
> '1 Park Avenue'],
> 'New York', 'NY']
>
> In other words how do you correctly nest the
> ['Apt 303'] so it goes with 33 Broadway Avenue.
>
> Also, I tried several ways and could not figure out
> how to get the ['Apt 303'] out of the list. How can
> you do that. It is the ['Apt 303'] that is the problem,
> I know how to do the other elements.
>
> thanks
> George
> --
> https://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Nested List question Andrew Farrell <amfarrell@mit.edu> - 2016-02-24 15:11 -0600
csiph-web