repl.it
@anonymous/

BlondCavernousExponents

Python

No description

fork
loading
Files
  • main.py
  • people-data.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
children_and_parents = {}

def read_data(filename):
  with open(filename) as f:
    for line in f.readlines():
      parent, child = line.rstrip("\n").split("->")
      if parent in children_and_parents:
        children_and_parents[parent] = (child)



read_data("people-data.txt")



def draw_family_tree(root, tree, level=0):
    if root:
        print(" " * level + root)

        if root in tree:
            for child in tree[root].child:
                draw_family_tree(tree, child, level + 3)