title: CS50 (2020) PSET6 DNA IndexError: list index out of range
body: <p>This has been a very difficult problem set for me, and I've had a tough time even getting something to work.  At this time this is what my code looks like; I can't even tell if it outputs anything because I can't get it to run without an error.  </p>
  
  <pre><code>import csv
  from cs50 import get_string
  from sys import argv
  
  if len(argv) != 3:
      print("Usage: python dna.py data.csv sequence.txt")
      exit()
  
  # Load Dictionary into the system
  with open(argv[1], 'r') as file:
      reader = csv.reader(file, delimiter=',')
      dna_data = list(reader)
      str_names = (dna_data[0][1:])
  
  # Load Text DNA Sequence into system
  text = open(argv[2], 'r')
  sequence = text.read()
  linecount = 0
  
  # occurrences of each str in dna sequence
  occurrences = []
  for i in range(0,len(str_names)):
      start = 0
      substr_count = 0
      consecutive = 0
      while True:
          string = sequence
          substring = str(dna_data[i])
          location = string.find(substring,start)
          if location == -1:
              break
          if location != start:
              consecutive = 1
          else:
              consecutive += 1
          if consecutive &gt; substr_count:
              substr_count = consecutive
          start = location + len(substring)
      occurrences.append(substr_count)
      substr_count = 0
  
  repeats = []
  match = 0
  name = 0
  for i in range (1, len(dna_data)):
      for j in range (1, len(dna_data[i])):
          repeats.append(dna_data[i][j])
      for k in range(1, len(dna_data)):
          if int(repeats[k]) == int(occurrences[k]): # THIS IS WHERE THE ERROR IS
              match += 1
              nomatch = False
          else:
              nomatch = True
      if match == len(occurrences) and nomatch == False:
          print(dna_data[i][0])
          name += 1
      else:
          nomatch = True
          match = 0
  if nomatch == True and name == 0:
      print("No Match")
  </code></pre>
  
  <p>I am sure the answer is probably something simple, but I just can't seem to figure it out.  I am pretty sure the list length of both "occurrences" and "repeats" are, in fact, both "len(dna_data)," but the error seems to state that k is increasing past the length of one of the lists.  Is there anything here that is obviously causing a problem?  How could I go about comparing the number present at position k within the repeats list and occurrences list? Thanks.</p>