title: Random choice on python file not working
body: <p>I am trying to do a flash card quiz challenge in Python. This involves taking the states and their capitals from a text file. I've managed to strip and split in order to create a dictionary with keys.</p>
  
  <p>But everytime I use random choice within the for loop it outputs the last key (e.g. Wyoming) On the other hand, when I take it out of the for loop, it only outputs the first key (e.g. Alabama)</p>
  
  <p>Here is what it looks like (obviously this doesn't show the text file)</p>
  
  <pre><code>import random
  with open("state_capitals.txt","r") as f:
  for line in f:
      cleanedLine = line.strip().split(',')
      state = cleanedLine[0]
      capital = cleanedLine[1]
      d = {}
      d[state] = capital
      while len(d)&gt;0:
          choice = random.choice(list(d.keys()))
  
          print("What is the capital city of",choice,"?")
          answer=input("Answer:  ")
  </code></pre>