Is there an meaning of '[[]]' in a list?
Peter Otten
__peter__ at web.de
Thu Nov 19 06:40:17 EST 2015
fl wrote:
> Hi,
> In the previous exercises, I see list:
> cc=[[],[],[]]
>
> Then, I can have this:
>
> ccc=[[[]],[[]],[[]]]
>
> I can also have
>
> ccc[0]
> Out[158]: [[]]
>
> ccc[0]='o'
>
> ccc
> Out[163]: ['o', [[]], [[]]]
>
>
> I have question: Is there any difference between [[]] and []?
> [[]] can have deeper assignment and use than
>
> ccc[0]='o'
I'm sure with a little effort and a few experiments on the commandline you
can answer your question yourself. Please limit your posts to c.l.py to
those questions that are a little harder.
Hint: when you experiment with nested lists use numbers, not strings as list
entries that are not lists themselves. Strings can confuse you about the
nesting level:
>>> items = ["foo"]
>>> items[0]
'foo'
>>> items[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
'f'
More information about the Python-list
mailing list