import random


def rand_string (l):
    """ Assigns 0 or 1 with equal probability to a gene of a chromosome of length l """

    string = [0]*l
    for i in range(0, l):
        if random.uniform(0,1) < 0.5:
            string[i] = 0
        else:
            string[i] = 1

    return string