[Tutor] Re: check for nested sequences & flatten
Thu, 14 Feb 2002 23:45:23 +0900
>Thirdly, what you've written is a max_depth() function (if you add +1 to the
That was what i was aiming for in another program. it's a bit more
all purpose that way, but for this i really am only concerned with
whether it is flat or nested.
>A function that only calculates is_nested() is easier:
> for item in L:
> is type(item) in (types.ListType, types.TupleType):
> return 1
> return 0
I copied this and the interpreter barfed. It said sytax error and pointed at the is type(item) in (types.ListType, types.TupleType):
line. Anyone see this syntax error, i can't. It looks ok to me
Love is in the Air!
Check out Cupid School where you will learn from Matchmaker's
best and brightest.
At Cupid School you'll learn how to pair up hopeful romantics
with one another, based on their personal preferences.
If you do well- you'll be rewarded with your own
set of love bow and arrows!