def mutCounter(individual):
 if (random.random() > 0.5):
  individual.update([random.choice(ITEMS_NAME)])
 else:
  val = random.choice(ITEMS_NAME)
  individual.subtract([val])
  if (individual[val] < 0):
   del individual[val]
 return (individual,)

def mutCounter ( individual ) : if ( random . random ( ) > 0.5 ) : individual . update ( [ random . choice ( ITEMS_NAME ) ] ) else : val = random . choice ( ITEMS_NAME ) individual . subtract ( [ val ] ) if ( individual [ val ] < 0 ) : del individual [ val ] return ( individual , )
adds or remove an item from an individual .