title: Reading through a text file to find a specific string and read another string related to it
body: <p>Before I get started I want to note that this is Homework and I do not want an answer on a silver platter(not that I expected that). I want help with my logic.</p>
  
  <p>I am trying to make a program that reads through the text file located <a href="http://www.cs.rit.edu/~csci141/Homeworks/HwkC/athletes.txt" rel="nofollow">here</a>.</p>
  
  <p>One function takes a parameter year and and looks through the file for that year and counts the medals won by athletes in that year and returns the total medals.</p>
  
  <p>A second function takes the year, athletes last name, and first name as parameters and reports that athletes medals won. I understand how to open the file, and how to use  a for loop and readline command. </p>
  
  <p>I do not know how I would go about getting the number of medals from the athlete if I am not directly looking for the number itself. If someone could assist me with reworking my logic that would be appreciated. I will post my code so far for reference.</p>
  
  <pre><code>def countByYear(year):
  line = 0
  medals = 0
  with open("athletes.txt", encoding= 'utf-8') as f:
      for line in f:
          s = f.readline()
          if s == year:
              break
              line2 = f.readline()
              for line2 in f:
                  if line2.isdigit():
                      int(line2)
                      medals+=line2
                      break
      print(medals)        
  </code></pre>