import random
import string


def mutate(gene, mutation_rate):
    """
    Make a random alteration to a gene string. Randomises letter according to
    the mutation rate.
    """
    new_gene = []
    for allele in gene:
        if random.random() < mutation_rate:
            new_gene.append(random.choice(string.ascii_lowercase))
        else:
            new_gene.append(allele)

    return "".join(new_gene)