russblau at hotmail.com
Tue Aug 31 19:38:02 CEST 2004
"Player" <asif at go-away-spammer.com> wrote in message
news:ch2c6b$5ap$1 at newsg1.svr.pol.co.uk...
> Firstly I just wanted to see if I could get the length out of those
elements > that were list type.
> I no thats not exactly what the exercise asks for, but I thought I would
> start there.
> However I am stuck and cant figure out why my code is doing what it's
> My code is as follows....
> mylist = [1, 2, ["three", "four"], "five"]
> for item in mylist:
> if item == type(list):
The "if" statement above is always false (well, at least for any list you
are likely to encounter in real life), because you are looking to see if the
item is equal to "type(list)" which is a type object. I think you meant:
if type(item) == list:
That's why your len() statement was never being reached.
> myitem = len(item)
> print myitem
> print item
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.
More information about the Python-list