0
import sys
import csv


def main():
    if len(sys.argv) != 3:
        print("Should be 3 command-line arguments ")
        sys.exit(1)


    with open(sys.argv[2], 'r') as f:
        for line in f:
            s = line

    with open(sys.argv[1], 'r') as f:
        reader = csv.DictReader(f)
        l = []
        for row in reader:
            l.append(row)

    dict_ = {}
    for i in l:
        for j in i.keys():
            dict_[j] = count_str(s, j)
    dict_.pop('name')
    for sub in l:
        for key in sub:
            try:
                sub[key] = int(sub[key])
            except:
                continue
    print(compare(dict_, l))


def compare(dict_, list_):
    for i in list_:
        name = i['name']
        i.pop('name')
        if dict_ == i:
            return name
            sys.exit(0)
    return 'No Match'


def count_str(dna, count):
    for i in range(len(dna) // len(count), 0, - 1):
        if count * i in dna:
            return i


if __name__ == "__main__":
    main()

when I run my program with python dna.py databases/large.csv sequences/7.txt or any of the tests, it works perfectly well. However, when I run it with check50 it just shows such a message for most of tests:

:( correctly identifies sequences/20.txt Did not find "No match\n" in ""

Moreover, without changing any piece of code, the test that fails differs from check to check.

You must log in to answer this question.

Browse other questions tagged .