title: How do you use a for loop to sort through a list from a text file and count the number of times it matches with a user inputted phrase?
body: <p>The file WorldSeriesWinners.txt contains a chronological list of the World Series winning teams from 1903 through 2014. The first line in the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2014. Note that the World Series was not played in 1904 or 1994.</p>
  <p>Write a program that lets the user enter the name of a team and then displays the number of times that team has won the World Series since 1903.</p>
  <p>Sample program runs are as follows:</p>
  <hr />
  <blockquote>
  <p>Enter team name: St. Louis Cardinals</p>
  <p>St. Louis Cardinals won 11 times</p>
  </blockquote>
  <hr />
  <blockquote>
  <p>Enter team name: Kansas City Royals</p>
  <p>Kansas City Royals won 1 times</p>
  </blockquote>
  <hr />
  <blockquote>
  <p>Enter team name: San Francisco Giants</p>
  <p>San Francisco Giants won 3 times</p>
  </blockquote>
  <hr />
  <blockquote>
  <p>Enter team name: Texas Rangers</p>
  <p>Texas Rangers won 0 times</p>
  </blockquote>
  <hr />
  <p>Format the ouput of your program as shown in the sample program runs. Design your program so that it contains at least one function other than the main function. No code should appear outside functions.</p>
  <p>Hint: You may want to read the contents of WorldSeriesWinners.txt into a list. When the user enters the name of a team, use a loop to step through the list, counting the number of times the selected team appears.</p>
  <p>What I have so far:</p>
  <pre><code>def readfile():
  
  f = open(&quot;WorldSeriesWinners.txt&quot;, &quot;r&quot;)
  lineList = f.readlines()
  f.close()
  
  List = []
  
  for line in lineList:
      line = line.strip()
      List.append(line)
  
  
  def main():
  
      name = input(&quot;Enter team name: &quot;)
      readfile()
  main()
  </code></pre>