[Tutor] (no subject) (fwd)

Eric Walstad eric at ericwalstad.com
Fri Jan 19 19:40:49 CET 2007


Hey Max,
Danny Yoo wrote:
> [Forwarding to tutor.  Can someone answer Max?  Slightly busy at the
> moment.  Quick note: get him to realize that the list he was playing
> with originally had three elements.  The example in his book has two
> elements. Something has to change.  *grin*]
> 
> 
> ---------- Forwarded message ----------
> Date: Fri, 19 Jan 2007 10:10:04 -0800 (PST)
> From: Max Jameson <max.jameson at sbcglobal.net>
> To: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
> Subject: Re: [Tutor] (no subject)
> 
[...]
> This is exactly how the tutorial reads (I omited the definition of the
> aList and anoterh):
>>>> aList.append(another)
>>>> print aList
> [42, [1, 2, 7]]
I suspect I didn't see the definition of 'aList' on Alan's website, but
the values look different than what you posted originally.

Based on the output above, I'd say:
aList = [42,]
another = [1, 2, 7]

Whereas your definition, in your original email:
aList = [2,3]
bList = [5,7,9]

Do you see the difference between the two (aside from the different
variable names)?


> I expected to get the third element of the second list printed
In your example, that would be the 'second' item in your bList (because
lists are zero-based):
bList[2] == 9

After 'append'ing bList to aList, aList has three items.  Try this at
the python command line:
print aList[0]
print aList[1]
print aList[2]

Two of those will be integers, One will be a list.

I hope that helps.

Eric.


More information about the Tutor mailing list