Hello, I'm trying to write this simple program that returns True if two equal-length strings are complimentary DNA pairs (ie, if character 1 in string 1 was 'A', character 1 in string 2 has to be 'T', and vice-versa, otherwise it would return false).
This is what I have so far:
The "_" is to show indentation.
However Python returns a "ValueError : too many values to unpack" error when I run it. I'm guessing it has to do with the line "for (base1, base2) in (strand1, strand2), but how to fix this error? Is there any way to show that I want two lists to be processed simultaneously, ie, character x of both strand1 and strand2?
Thanks.
This is what I have so far:
Code:
[B]for[/B] (base1, base2) [B]in [/B](strand1, strand2): [B]if[/B] (base1, base2) [B]not in[/B] (('A', 'T'), ('T', 'A'), ('C', 'G'), ('G', 'C')): [B]return False[/B] [B]return True[/B]
However Python returns a "ValueError : too many values to unpack" error when I run it. I'm guessing it has to do with the line "for (base1, base2) in (strand1, strand2), but how to fix this error? Is there any way to show that I want two lists to be processed simultaneously, ie, character x of both strand1 and strand2?
Thanks.
Comment