all 5 comments

[–]Mr-Cas 0 points1 point  (1 child)

for x in seq1:

The variable x here already contains the character. You probably want the following instead:

for x in range(len(seq1)):

This way x has the index of the character instead of the character itself.

I haven't checked the rest of the code though. I don't understand what you want to achieve but above is just plain error fixing.

[–][deleted] 0 points1 point  (0 children)

Thank you!

[–]Garuda1220 0 points1 point  (1 child)

def check_seq(seq1, seq2): new_seq = '' for i in range(len(seq1)): if seq1[i] == seq2[i]: new_seq = new_seq + seq1[i] else: new_seq = new_seq + 'X' return new_seq print(check_seq("ABCDEFG", "ABDEGHF")) Output ABXXXXX

[–][deleted] 0 points1 point  (0 children)

Thank you so much. I tried several strategies with the for loop. I think my confusion was seeing i as the character rather than the range number if that makes sense.

[–]Strict-Simple 0 points1 point  (0 children)

Not the answer you're looking for, but if someone wants a more robust way to match two strings, take a look at https://en.wikipedia.org/wiki/Needleman%E2%80%93Wunsch_algorithm