a adam book 4 b bill computer 5 tv 6 jill sports 1 c bill sports 3 d adam computer 3 quin computer 3 e quin book 5 tv 2 f adam computer 7 a adam book 4 b bill computer 5 tv 6 jill sports 1 c bill sports 3 d adam computer 3 quin computer 3 e quin book 5 tv 2 f adam computer 7 end prevents a newline character multiple lookups is expensive even amortized o 1 op wants indenting after digits newline and a space to match indenting forces a newline
from __future__ import print_function


def tree_print(tree):
    for key in tree:
        print(key, end=' ')  
        tree_element = tree[key]  
        for subElem in tree_element:
            print(" -> ", subElem, end=' ')
            if type(subElem) != str:  
                print("\n ")  
        print()