New answers tagged

1

This elif(a == True and r[0] == 3 and r[1] == 4 or 7): will always evaluate to True because 7 is "truthy". Did you mean or r[1] == 7? And once an or introduced, the expression will likely need parentheses. Same goes for the subsequent elif.


0

I found the fix finally: if s.argv[1] == 'databases/large.csv': # NOTE - this is adapted from: https://stackoverflow.com/questions/61131768/how-to-count-consecutive-substring-in-a-string-in-python-3 for i in str_list: expected = i str_max = 0 while expected in read_s: str_max += 1 ...


0

def main(): if len(sys.argv) != 3: sys.exit("Usage: python dna.py data.csv sequence.txt") # some placeholding lists memory = [] database = sys.argv[1] seq = sys.argv[2] with open(database, "r") as fdata, open(seq, "r") as sequence: reader = csv.DictReader(fdata) ...


0

Your observation[key] is an integer. row[key] is a string. When you do observation[key] != row[key], (In this case 4 != '4')it will be true, breaking the loop. So to fix this issue, do observation[key] != int(row[key])


0

I found the problem. It turned out that I forgot the reset the counter in else condition. Also, my while loop should be less than or equal instead of just less than and I don't need if condition to check whether i + len(dna_str) > len(sequence) since I am already checking it in my while statement. Correct code of function get_max_str_repeats() is below. ...


Top 50 recent answers are included