[Tutor] Request for help learning the right way to deal with listsin lists
Payal
payal-python at scriptkitchen.com
Thu Jul 15 14:09:24 CEST 2010
On Tue, Jul 13, 2010 at 08:35:45AM +0100, Alan Gauld wrote:
> If the data gets more complex you could put the data into a class:
>
> class Book:
> def __init__(self, title, pages=[]):
> self.title = title
> self.pages = pages
>
> Books = [ Book('War & Peace", [3,56,88]),
> Book("Huck Finn", [2,5,19]) ]
Can someone please explain the above 2 lines?
> for book in Books:
> print book.title, book.pages
With warm regards,
-Payal
--
More information about the Tutor
mailing list