Exercise 1 solution def reverse_complement(s): return s.translate(str.maketrans("ACGT", "TGCA"))[::-1] for s in ("ATGC", "GGGATTT", "AAAACCCGGT"): rc = reverse_complement(s) print(s, rc, reverse_complement(rc) == s) print(reverse_complement("GAATTC") == "GAATTC") print(reverse_complement("GGATCC") == "GGATCC") Output: ATGC GCAT True GGGATTT AAATCCC True AAAACCCGGT ACCGGGTTTT True True True Reading it: applying the function twice always returns the original, because complementing and reversing each undo themselves. GAATTC and GGATCC are palindromic in this sense: they read the same as their own reverse complement. (Short sequences like these are often cut by enzymes used in the laboratory; check before relying on that.)