<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def crossover(dna1, dna2):
 """crossover dna1 and dna2 at a random index"""

    pos = int(random.random()*len(dna1))
    if random.random() < 0.5:
        return (dna1[:pos]+dna2[pos:], dna2[:pos]+dna1[pos:])
    else:
        return (dna2[:pos]+dna1[pos:], dna1[:pos]+dna2[pos:])