def mutSet(individual):
 if (random.random() < 0.5):
  if (len(individual) > 0):
   individual.remove(random.choice(sorted(tuple(individual))))
 else:
  individual.add(random.randrange(NBR_ITEMS))
 return (individual,)

def mutSet ( individual ) : if ( random . random ( ) < 0.5 ) : if ( len ( individual ) > 0 ) : individual . remove ( random . choice ( sorted ( tuple ( individual ) ) ) ) else : individual . add ( random . randrange ( NBR_ITEMS ) ) return ( individual , )
mutation that pops or add an element .