title: Text file to Tuple to Dictionary in Python
body: <p>I have a text file that contains the following information:</p>
  
  <pre><code>Britney 2 3 4 5 1 23 6
  Jessica 5 1 5 3 2 33 1 5 2 5 61 2
  Mathew 2 33 1 4 2 5 5 2 3 
  Sofia 8 3 1 2 3 52 1 5 2 3 51 25 23 1 2 6
  </code></pre>
  
  <p>I am supposed to write a function that takes the name and assigns it as a key in a <code>dictionary</code></p>
  
  <p>As for the value of the key, that's a bit more complicated.</p>
  
  <p>The function needs to read through the numbers, the FIRST number (starting from left to right) indicates HOW MANY numbers will be in the TUPLE. And then it goes through the number and picks the second number - nth number.</p>
  
  <p>For example.</p>
  
  <pre><code>Britney 2 3 4 5 1 23 6
  </code></pre>
  
  <p>The first number <code>2</code> indicates that the NEXT two number will be the tuple value for the key <code>Britney</code>. So Britney has the value <code>(3, 4)</code></p>
  
  <p>Likewise:</p>
  
  <pre><code>Sofia 8 3 1 2 3 52 1 5 2 3 51 25 23 1 2 6
  </code></pre>
  
  <p><code>Sofia</code> has the value <code>(3, 1, 2, 3, 52, 1, 5, 2)</code></p>
  
  <p>I was thinking along the lines of:</p>
  
  <pre><code>input_file = open("namesandnumbers.txt", "r")
  the_dict = {}
  for line in input_file:
      initial = line.replace("\n","").split(" ")
      key = initial[0]
  </code></pre>
  
  <p>but I can't figure out what to do next, and I am unsure about using <code>split(" ")</code> as there is space between the name and numbers, but between numbers themselves as well.</p>