Mega Code Archive

 
Categories / Python / List
 

Nest lists (create lists containing other lists)

q = [2, 3] p = [1, q, 4] print len(p) print p[1] print p[1][0] p[1].append('xtra') print p print q #p[1] and q really refer to the same object!