Question | Count Branches
Define count_branches
, which takes a non-rooted tree t
, and returns the number of branches in t
. You may assume is_leaf(tree)
is defined for you.
def count_branches(t):
"""
>>> t1 = [1, [2, 3], [3, [4, 3]]]
>>> count_branches(t1)
9
>>> t2 = [2]
>>> count_branches(t2)
1
"""
## YOUR CODE HERE ##