import random


def two_point_crossover(dna1, dna2):
    """crossover dna1 and dna2 at 2 random indices"""
    pos1, pos2 = sorted(random.sample(range(len(dna1)), 2))
    child1 = dna1[:pos1]+dna2[pos1:pos2]+dna1[pos2:]
    child2 = dna2[:pos1]+dna1[pos1:pos2]+dna2[pos2:]
    return (child1, child2)