title: How can I show all the complete message of the algorithm?
body: <p>I’m trying to create a binary tree about the Morse Code.
  The program should show all the message but for some reason it only prints the first letter.
  What should I do?</p>
  <pre><code>class Tree: 
  
      def __init__(self, data):
          self.data = data
          self.izq = None
          self.der = None
  
  Arriba = Tree (&quot;    &quot;)
  
  Arriba.izq = Tree(&quot;E&quot;)
  
  Arriba.der = Tree(&quot;T&quot;)
  
  Arriba.izq.izq = Tree(&quot;I&quot;)
  
  Arriba.izq.der = Tree(&quot;A&quot;)
  
  Arriba.der.izq = Tree(&quot;N&quot;)
  
  Arriba.der.der = Tree(&quot;M&quot;)
  
  Arriba.izq.izq.izq = Tree(&quot;S&quot;)
  
  Arriba.izq.izq.der = Tree(&quot;U&quot;)
  
  Arriba.izq.der.izq = Tree(&quot;R&quot;)
  
  Arriba.izq.der.der = Tree(&quot;W&quot;)
  
  Arriba.der.izq.izq = Tree(&quot;D&quot;)
  
  Arriba.der.izq.der = Tree(&quot;K&quot;)
  
  Arriba.der.der.izq = Tree(&quot;G&quot;)
  
  Arriba.der.der.der = Tree(&quot;O&quot;)
  
  Arriba.izq.izq.izq.izq = Tree(&quot;H&quot;)
  
  Arriba.izq.izq.izq.der= Tree(&quot;V&quot;)
  
  Arriba.izq.izq.der.izq = Tree(&quot;F&quot;)
  
  Arriba.izq.der.izq.izq = Tree(&quot;L&quot;)
  
  Arriba.izq.der.der.izq = Tree(&quot;P&quot;)
  
  Arriba.izq.der.der.der = Tree(&quot;J&quot;)
  
  Arriba.der.izq.izq.izq = Tree(&quot;B&quot;)
  
  Arriba.der.izq.izq.der = Tree(&quot;X&quot;)
  
  Arriba.der.izq.der.izq = Tree(&quot;C&quot;)
  
  Arriba.der.izq.der.der = Tree(&quot;Y&quot;)
  
  Arriba.der.der.izq.izq = Tree(&quot;Z&quot;)
  
  Arriba.der.der.izq.der = Tree(&quot;Q&quot;)
  
  texto = input(&quot;Digite el mensaje cifrado: &quot;)
  
  index = 0
  def Cositas (Arriba):
      global index
    
      for i in texto[index]:
          lista  = []
      
          if i == &quot;.&quot;:
              index += 1
              Cositas (Arriba.izq)
      
          elif i == &quot;-&quot;:
              index +=1
              Cositas (Arriba.der)
  
          elif i == &quot; &quot;:
              index += 1
              lista.append(Arriba.data)
  
          elif i == &quot;/&quot; :
              index += 1
              lista.append(&quot;---&quot;)
        
  
      for j in lista:
          print(&quot;Su mensaje es:&quot;)
          print(j,end=&quot;&quot;)
  
  Cositas(Arriba)
  </code></pre>