title: How to add numbers from a file into a list?
body: <p>I am trying to read a file that has a list of numbers in each line. I want to take only the list of numbers and not the corresponding ID number and put it into a single list to later sort by frequencies in a dictionary.  </p>
  
  <p>I've tried to add the numbers into the list and I am able to get just the numbers that I need but I can not get it to add to the list correctly. </p>
  
  <p>I have the function to read the file and to find just the location that I want to read from the line. I then try to add it to the list but it continues to come up like:</p>
  
  <pre><code>['23,43,56,', '67,87,34',]
  </code></pre>
  
  <p>And I want it to look like this: </p>
  
  <pre><code>[23, 43, 56, 67, 87, 34]
  </code></pre>
  
  <p>Here is my Code</p>
  
  <pre><code>def frequency():
  f = open('Loto4.txt', "r")
  list = []
  
      for line in f:
          line.strip('\n')
          start = line.find("[")
          end = line.find("]")
          line = line[start+1:end-1]
          list.append(line)
          print(line)
  
     print(list)
  frequency()
  </code></pre>
  
  <p>This is the file that I am reading: </p>
  
  <p>1:[36,37,38,9]</p>
  
  <p>2:[3,5,28,25]</p>
  
  <p>3:[10,14,15,9]</p>
  
  <p>4:[23,9,31,41]</p>
  
  <p>5:[5,2,21,9]</p>