I have nearly completed DNA in Pset6 of CS50 but I am having difficulty on the last section. I have managed to populate each of the max_AGATC, max_TTTTTTCT, max_AATG etc. with the correct values from the given sequence and I have checked that these are correct. For example, if I input sequence 10 into the full code, I get the following values:

  • max_AGATC =15
  • max_TTTTTTCT = 49
  • max_AATG = 38
  • max_TCTAG = 5
  • max_GATA = 14
  • max_TATC = 44
  • max_GAAA = 14
  • max_TCTG = 12

These correspond exactly to Albus' DNA

It also appears that each row[] is populating correctly. However, when I try and compare the two figures, they are are not being identified as such and the outcome of this is that every sequence identifies as a no match. Any ideas what I am doing wrong? (nb people_count always ends up being 23 and I have imported csv)

database_original = open(argv[1], "r")
database_read = csv.DictReader(database_original)

n = 0
for row in database_read:
    if row['AGATC'] == max_AGATC and row['TTTTTTCT'] == max_TTTTTTCT and row['AATG'] == max_AATG and row['TCTAG'] == max_TCTAG and row['GATA'] == max_GATA and row['TATC'] == max_TATC and row['GAAA'] == max_GAAA and row['TCTG'] == max_TCTG:
    n += 1
    if n == people_count:
        print('No match')

1 Answer 1


SO I've had that exact problem a couple of hours ago.

you are not actually comparing an int to an int

think about the type of MAX_AGATC and the type that you will get from the key 'AGATC'

you will get a string from 'AGATC' so you need to str(MAX_AGATC) and they will be the same type and the values will be compared properly

same goes for the rest of them ofc GL :D


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .