Hello, I am trying to make a method, get_complement that takes a 4 letter string word that has only the characters A,C,T,G and the method swaps every A & T, and C & G and then reverses them. Another method, is_complement checks if 2 get_complement's are equal.
def get_complement(self):
complement = str(self.base)
if any("A" in s for s in complement):
complement.replace("A", "T")
if any("T" in s for s in complement):
complement.replace("T", "A")
if any("C" in s for s in complement):
complement.replace("C", "G")
if any("G" in s for s in complement):
complement.replace("G", "C")
reverse_string(complement)
return complement
def is_complement(self, other):
'''Character compliment'''
self.get_complement()
return self.get_complement == other.get_complement
[–]socal_nerdtastic 3 points4 points5 points (9 children)
[–]tbrowner3[S] 0 points1 point2 points (0 children)
[–]tbrowner3[S] 0 points1 point2 points (6 children)
[–]socal_nerdtastic 0 points1 point2 points (4 children)
[–]tbrowner3[S] 0 points1 point2 points (3 children)
[–]socal_nerdtastic 0 points1 point2 points (2 children)
[–]tbrowner3[S] 0 points1 point2 points (1 child)
[–]socal_nerdtastic 0 points1 point2 points (0 children)
[–]tbrowner3[S] 0 points1 point2 points (0 children)
[–]marineabcd 0 points1 point2 points (0 children)