Exercise 2 solution def gc(s): return (s.count("G") + s.count("C")) / len(s) seqs = {"s1": "ATGCATGCAT", "s2": "GGCCGGCCAA", "s3": "ATATATATAT", "s4": "GCGCGCGCGC"} for name, s in sorted(seqs.items(), key=lambda kv: gc(kv[1])): print(name, s, round(gc(s), 2)) print(max(seqs, key=lambda k: gc(seqs[k]))) Output: s3 ATATATATAT 0.0 s1 ATGCATGCAT 0.4 s2 GGCCGGCCAA 0.8 s4 GCGCGCGCGC 1.0 s4 Reading it: sorted with a key function orders the items by their GC content, and max with the same idea picks the highest. The sequence with only G and C bases scores 1.0 and the one with only A and T scores 0.0.