""" Using recursion to count. """ def count(n): if n <= 10: print n count(n+1) count(1) def loop(start, stop, function): if start <= stop: function(start) loop(start+1, stop, function) def print_it(x): print x loop(100, 110, print_it) # An example of a tree as a fancy # python data structure tree = {'name':'start', 'kids': [ {'name':'a1', 'kids':[ {}, {} ]}, {'name':'a2', 'kids':[ ]}, {'name':'a3', 'kids':[ ]} ]} def count_nodes(tree): """Return how many nodes in tree total"