diff --git a/u9/huffman_tree.py b/u9/huffman_tree.py index 6884d4b..0c0df43 100644 --- a/u9/huffman_tree.py +++ b/u9/huffman_tree.py @@ -24,11 +24,11 @@ class HuffmanTree: if not found: nodes.append(HuffmanNode(char,1)) - while len(nodes) > 1: - first = 0 - second = 1 - if nodes[first].frequency > nodes[second].frequency: - first, second = second, first + while len(nodes) > 1: + first = 0 + second = 1 + if nodes[first].frequency > nodes[second].frequency: + first, second = second, first for i in range(2, len(nodes)): if nodes[i].frequency < nodes[first].frequency: