Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99042 > unrolled thread

Is there an meaning of '[[]]' in a list?

Started byfl <rxjwg98@gmail.com>
First post2015-11-19 03:28 -0800
Last post2015-11-19 16:26 +0000
Articles 8 — 7 participants

Back to article view | Back to comp.lang.python


Contents

  Is there an meaning of '[[]]' in a list? fl <rxjwg98@gmail.com> - 2015-11-19 03:28 -0800
    Re: Is there an meaning of '[[]]' in a list? Nagy László Zsolt <gandalf@shopzeus.com> - 2015-11-19 12:36 +0100
    Re: Is there an meaning of '[[]]' in a list? Peter Otten <__peter__@web.de> - 2015-11-19 12:40 +0100
      Re: Is there an meaning of '[[]]' in a list? Quivis <quivis@domain.invalid> - 2015-11-22 23:25 +0000
        Re: Is there an meaning of '[[]]' in a list? Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-22 19:08 -0500
        Re: Is there an meaning of '[[]]' in a list? Peter Otten <__peter__@web.de> - 2015-11-23 09:57 +0100
        Re: Is there an meaning of '[[]]' in a list? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 12:04 +0100
    Re: Is there an meaning of '[[]]' in a list? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-19 16:26 +0000

#99042 — Is there an meaning of '[[]]' in a list?

Fromfl <rxjwg98@gmail.com>
Date2015-11-19 03:28 -0800
SubjectIs there an meaning of '[[]]' in a list?
Message-ID<750e1071-395b-4e9b-ad64-05faa174a5bf@googlegroups.com>
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'


Thanks,

[toc] | [next] | [standalone]


#99043

FromNagy László Zsolt <gandalf@shopzeus.com>
Date2015-11-19 12:36 +0100
Message-ID<mailman.453.1447933015.16136.python-list@python.org>
In reply to#99042
> I have question: Is there any difference between [[]] and []?
Yes.

[] - a list with zero elements. That is an empty list.
[[]] - A list with one element. (That element is an empty list.)

> [[]] can have deeper assignment and use than 
You can have it as deep as you want, if you have enough memory.

[toc] | [prev] | [next] | [standalone]


#99045

FromPeter Otten <__peter__@web.de>
Date2015-11-19 12:40 +0100
Message-ID<mailman.454.1447933236.16136.python-list@python.org>
In reply to#99042
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'

[toc] | [prev] | [next] | [standalone]


#99245

FromQuivis <quivis@domain.invalid>
Date2015-11-22 23:25 +0000
Message-ID<V9s4y.489754$6i2.102301@fx35.am4>
In reply to#99045
On Thu, 19 Nov 2015 12:40:17 +0100, Peter Otten wrote:

> those questions that are a little harder

And just how is he going to determine what is hard?
-- 
  _____  __ __ __ __ __ __   __
 ((   )) || || || \\ // ||  ((
  \\_/X| \\_// ||  \V/  || \_))
   Omnia paratus  *~*~*~*~*~*~*

[toc] | [prev] | [next] | [standalone]


#99250

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2015-11-22 19:08 -0500
Message-ID<mailman.56.1448237333.2291.python-list@python.org>
In reply to#99245
On Sun, Nov 22, 2015 at 6:25 PM, Quivis <quivis@domain.invalid> wrote:

> On Thu, 19 Nov 2015 12:40:17 +0100, Peter Otten wrote:
>
> > those questions that are a little harder
>
> And just how is he going to determine what is hard?
> --
>   _____  __ __ __ __ __ __   __
>  ((   )) || || || \\ // ||  ((
>   \\_/X| \\_// ||  \V/  || \_))
>    Omnia paratus  *~*~*~*~*~*~*
> --
> https://mail.python.org/mailman/listinfo/python-list
>

from the OP:
Hi,
In the previous exercises, I see list:
cc=[[],[],[]]

This seems to refer to some tutorial maybe?

I suppose there could be some value in an exercise like this, but I don't
see it.

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays

[toc] | [prev] | [next] | [standalone]


#99259

FromPeter Otten <__peter__@web.de>
Date2015-11-23 09:57 +0100
Message-ID<mailman.62.1448269230.2291.python-list@python.org>
In reply to#99245
Quivis wrote:

> On Thu, 19 Nov 2015 12:40:17 +0100, Peter Otten wrote:
> 
>> those questions that are a little harder
> 
> And just how is he going to determine what is hard?

Note that I said "a little harder", not "hard".

Write down your next ten or so questions, then work through the tutorial or 
another introductory text, then use a search engine, then post the one or 
two questions that are still unanswered.

[toc] | [prev] | [next] | [standalone]


#99437

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2015-11-25 12:04 +0100
Message-ID<mailman.66.1448449446.20593.python-list@python.org>
In reply to#99245
Op 23-11-15 om 09:57 schreef Peter Otten:
> Quivis wrote:
>
>> On Thu, 19 Nov 2015 12:40:17 +0100, Peter Otten wrote:
>>
>>> those questions that are a little harder
>> And just how is he going to determine what is hard?
> Note that I said "a little harder", not "hard".
>
> Write down your next ten or so questions, then work through the tutorial or 
> another introductory text, then use a search engine, then post the one or 
> two questions that are still unanswered.

The problem is of course that he may already be doing that. We have just
no idea about which questions he solved for himself because those are
not mentioned here.

But I do agree that he probably should try harder, he doesn't seem to
come with the result of an experiment he tried where the result surprised
him.

-- 
Antoon.

[toc] | [prev] | [next] | [standalone]


#99070

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-11-19 16:26 +0000
Message-ID<mailman.468.1447950397.16136.python-list@python.org>
In reply to#99042
On 19/11/2015 11:28, 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'
>
>
> Thanks,
>

I have question.  Is there any chance that you stop wasting the time of 
people on this list by either doing your own research or trying things 
at an interactive prompt?  Or are you now well past that point, as 
you're learned that the extremely generous people here have fitted your 
bibs, spoon fed you and and changed your nappies so many times that it 
has rendered you incapable of doing anything for yourself?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web