title: How can I add variables into a dictionary with a loop?
body: <p>I'm pretty new to python and I'm trying to create loops that are capable of doing all the work that I did by hand. Essentially creating all the <strong>line'#'</strong> variables and assigning them the particular line of text from the file <em>'game_catch.txt'</em> which reads something like this:</p>
  
  <pre><code>Curving                 10
  Dodgeball               15
  Keep Away               5
  Kin-Ball                7
  Prisoner Ball           21
  Quidditch               30
  Rundown (aka Pickle)    12
  Yukigassen              18
  Handball                25
  </code></pre>
  
  <p>(With the spaces being Tabs, if that makes any difference)</p>
  
  <p>Then creating another loop that assigns the value of the <strong>line'#'</strong> variables to <strong>str'#'</strong> variables while splitting all the spacing away. (I cannot modify the file because in other computers it will be the same as the one I posted above, so I have to do this step)</p>
  
  <p>Then, and more importantly because this is where I'm completely stuck, making a loop for doing all the nitty gritty work of turning the <strong>str'#'</strong> variables into something the sports dictionary can pick up and then read as <strong>{'Curving': 10}</strong></p>
  
  <p>Here I provided the code I'm currently using and trying to simplify:</p>
  
  <pre><code>file = open('game_catch.txt','r')
  line1 = file.readline()
  line2 = file.readline()
  line3 = file.readline()
  line4 = file.readline()
  line5 = file.readline()
  line6 = file.readline()
  line7 = file.readline()
  line8 = file.readline()
  line9 = file.readline()
  
  str1 = line1.split()
  str2 = line2.split()
  str3 = line3.split()
  str4 = line4.split()
  str5 = line5.split()
  str6 = line6.split()
  str7 = line7.split()
  str8 = line8.split()
  str9 = line9.split()
  
  sports = {}
  
  key = ''
  for i in str1[0:-1] :
      key += i + ' '
  
  key = key[0:-1]
  
  sports[key] = int(str1[-1])
  </code></pre>
  
  <p>Sorry for the long post, I just wanted to provide as much detail as possible. Feel free to let me know if there are more efficient ways of doing this. Thanks</p>