-2
def height (t):
  if not t:
    return 0                                   # (1)
  elif not t.nodes:
    return 1                                   # (2)
  else:
    return 1 + max(height(n) for n in t.nodes) # (3)

hello guys some one can help me and change this function to pipline? using map , filter , lambda

you don't need to write def height you need to use only with lambda map filter (PIPLINE)

Roni Jack Vituli
  • 123
  • 2
  • 13

1 Answers1

1

Since you only return 0 if not t, and for other cases you return 1, you could go with this simple line:

return 0 if not t else 1 if not t.nodes else 1 + max(height(n) for n in t.nodes)
Gal Birka
  • 581
  • 6
  • 16