title: How to split lines in a file and put data into a dictionary in python
body: <p>I am trying read a txt file and put the data into a dictionary. My file looks something like this:</p>
  
  <pre><code>Alex:3
  John:6
  Sam:8
  </code></pre>
  
  <p>Basically, a word and integer separated by a colon. I want to open and read the file, split each line where the colon is, and put the data into a dictionary like this:</p>
  
  <p>{'Alex':3, 'John':6, 'Sam':8}</p>
  
  <p>So far my code looks like this:</p>
  
  <pre><code>d = {}
  f = open('scores.txt', 'r')
  for line in f.readlines():
      line = line.strip()
      name = line.split(":")
  </code></pre>
  
  <p>How do I assign the name as the key and the integer as the value and put it into the dictionary?</p>