Jump to content


Member Since 27 Sep 2014
Offline Last Active Sep 28 2014 07:10 AM

Topics I've Started

Chp1 Nesting Issue

27 September 2014 - 09:35 AM

I'm having trouble with getting all of the list items to print. My output is missing "Graham Chapman".

Here is my movies list:

>>> print(movies)
['The Holy Grail', 1975, 'Terry Jones & Terry Gilliam', 91, ['Graham Chapman', ['Michael Palin', 'John Cleese', 'Terry Gilliam', 'Eric Idle', 'Terry Jones']]]

I then copied the code from the book and still can't get "Graham Chapman":

>>> for each_item in movies:
	if isinstance(each_item, list):
		for nested_item in each_item:
			if isinstance (nested_item, list):
				for deeper_item in nested_item:
				else: print(nested_item)
		print (each_item)

The Holy Grail
Terry Jones & Terry Gilliam
Michael Palin
John Cleese
Terry Gilliam
Eric Idle
Terry Jones
['Michael Palin', 'John Cleese', 'Terry Gilliam', 'Eric Idle', 'Terry Jones']

After '91' I'm missing "Graham Chapman" .

What am I doing wrong here?