title: Python File IO - building dictionary and finding max value
body: <p>Problem is to return the name of the event that has the highest number of participants in this text file: </p>
  
  <pre><code>#Beyond the Imposter Syndrome 
  32 students 
  4 faculty 
  10 industries 
  #Diversifying Computing Panel
  15 students 
  20 faculty 
  #Movie Night 
  52 students 
  </code></pre>
  
  <p>So I figured I had to split it into a dictionary with the keys as the event names and the values as the sum of the integers at the beginning of the other lines. I'm having a lot of trouble and I think I'm making it too complicated than it is. </p>
  
  <p>This is what I have so far: </p>
  
  <pre><code>def most_attended(fname):
      '''(str: filename, )'''
      d = {}
      f = open(fname)
      lines = f.read().split(' \n')
      print lines
      indexes = []
      count = 0
      for i in range(len(lines)):
          if lines[i].startswith('#'):
              event = lines[i].strip('#').strip()
              if event not in d:
                  d[event] = []
              print d
              indexes.append(i)
              print indexes
          if not lines[i].startswith('#') and indexes !=0:
              num = lines[i].strip().split()[0]
              print num 
              if num not in d[len(d)-1]:
                  d[len(d)-1] += [num]
      print d
  
      f.close()
  </code></pre>