title: Create a list dynamically and store all the values matching with current value in python 3.x
body: <p>I have a text file which has data created dynamically like </p>
  
  <pre><code>1000L 00V
  2000L -10V
  3500L -15V
  1250L -05V
  1000L -05V
  2000L -05V
  6000L -10V
  1010L 00V
  </code></pre>
  
  <p>and so on...</p>
  
  <p>The numbers before V could vary from <code>-160 to +160</code></p>
  
  <p>I want to create a list (not using dictionary) dynamically and store the values in a list according to the matching numbers before <code>V</code></p>
  
  <p>In this case I want to create sets of list as follows</p>
  
  <pre><code> 00 = ["1000", "1010"]
  -10 = ["2000", "6000"]
  -15 = ["3500"]
  -05 = ["1250", "1000", "2000"]
  </code></pre>
  
  <p>Tried code:</p>
  
  <pre><code>if name.split()[1] != "":
      gain_value = name.split()[1]
      gain_value = int(gain_value.replace("V", ""))
      if gain_value not in gain_list:
          gain_list.append(gain_value)
          gain_length = len(gain_list)
          print(gain_length)
          g['gain_{0}'.format(gain_length)] = []
          'gain_{0}'.format(gain_length).append(L_value)
      else:
          index_value = gain_list.index(gain_value)
          g[index_value].append(L_value)
  
  for x in range(0, len(gain_list)):
      print(str(gain_list[x]) + "=" + 'gain_{0}'.format(x))
  </code></pre>
  
  <p>But the above code doesn't work as I get an error while appending <code>'gain_{0}'.format(gain_length).append(L_value)</code> and I am unsure how to print the list dynamically after its created as mentioned in my required output. </p>
  
  <p>I can't use dictionary for the above method because I want to give the lists dynamically as input to <strong>pygal module</strong> as below:</p>
  
  <p>as I need the output for pygal module as input like :</p>
  
  <pre><code>for x in range(0, gain_length):
      bar_chart.x_labels = k_list
      bar_chart.add(str(gain_length[x]),'gain_{0}'.format(x))
  </code></pre>
  
  <p>Here I can add the values only from a list not from a dictionary </p>