title: Trying to Find Most Occurring Name in a File
body: <p>I have 4 text files that I want to read and find the top 5 most occurring names of. The text files have names in the following format "Rasmus,M,11". Below is my code which right now is able to call all of the text files and then read them. Right now, this code prints out all of the names in the files.</p>
  
  <pre><code>def top_male_names ():
      for x in range (2008, 2012):
          txt = "yob" + str(x) + ".txt"
          file_handle = open(txt, "r", encoding="utf-8") 
  
          file_handle.seek(0)
  
          line = file_handle.readline().strip()
  
          while line != "":
              print (line)
              line = file_handle.readline().strip()
  
  top_male_names()
  </code></pre>
  
  <p>My question is, how can I keep track of all of these names, and find the top 5 that occur the most? The only way I could think of was creating a variable for each name, but that wouldn't work because there are 100s of entries in each text file, probably with 100s of different of names. </p>