[Tutor] (no subject)

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri Jan 19 18:41:53 CET 2007



On Fri, 19 Jan 2007, Max Jameson wrote:

> I know this is totally off-the-wall, but what am I doing wrong here?  I 
> am using Python 2.5, and I am just learning...please be kind!


Hi Max,

Let's take a look.


###########################################
>>> aList = [2,3]
>>> bList = [5,7,9]
>>> aList.append(bList)
>>> print aList
[2, 3, [5, 7, 9]]
###########################################

Ok, looks good so far.  You have a list of three elements:

     2
     3
     [5, 7, 9]

where the third element in the list is itself a list.



###########################################
>>> print aList [1] [2]
Traceback (most recent call last):
   File "<pyshell#40>", line 1, in <module>
     print aList [1] [2]
TypeError: 'int' object is unsubscriptable
###########################################

Can you explain what you're trying to do at this point?  Pretend that we 
are clueless for the moment.

What are you expecting to get out from this?  We know you don't want to 
get the error, of course.  But what do you want to get?


Also, have you had a chance to look at something like:

    http://swaroopch.info/text/Byte_of_Python:Data_Structures


More information about the Tutor mailing list