Exercise 2 solution COMP = str.maketrans("ACGT", "TGCA") def revcomp(s): return s.translate(COMP)[::-1] seq = "TTGAATTCAAGGATCCGCGCAATTAGAATTCC" sites = [] for i in range(len(seq) - 5): piece = seq[i:i + 6] if piece == revcomp(piece): sites.append((i, piece)) print(sites) print(len(sites)) print(revcomp("GAATTC") == "GAATTC", revcomp("GGATCC"), revcomp("ATGGCC")) Output: [(2, 'GAATTC'), (10, 'GGATCC'), (25, 'GAATTC')] 3 True GGATCC GGCCAT Reading it: a six-letter site reads the same as its own reverse complement, so it is a palindrome in the DNA sense: GAATTC and GGATCC pass, ATGGCC does not. Three sites turn up, at positions 2, 10 and 25 (counting from 0). Sites like these are where many restriction enzymes cut (check).