So I have this for a sound crew to select jobs for workers based on the training they have recieved. My code allows you to add workers to the list and set what jobs they are allowed to do through use of inputs. The second Function then randomly creates job assignments for people based on the parameters in the first function. I would like to be able to have people selected, with no repeats, and preferably without permanently deleting people from the lists, so that the lists can be saved permanently.
With the current code i get the error ValueError: list.remove(x): x not in list.

What do you think I am missing guys? Thanks for all input!

import random

my_list = []
stage_list = []
mic_list = []
sound_list = []

def addto_list():
    addto = input()
    stage = input("Can he do stage?(y/n): ")
    if stage == "y":
        stage_list.append(addto)

    mic = input("Can he do mic?(y/n): ")
        if mic == "y":
        mic_list.append(addto)

    sound = input("Can he do sound?(y/n): ")
        if sound == "y":
        sound_list.append(addto)

    my_list.append(addto)

def create_assignment():
    stage_assign = random.choice(stage_list)
    stage_list.remove(stage_assign)
    mic_list.remove(stage_assign)
    sound_list.remove(stage_assign)
    print("Stage: " + stage_assign)

    micleft_assign = random.choice(mic_list)
    mic_list.remove(micleft_assign)
    stage_list.remove(micleft_assign)
    sound_list.remove(micleft_assign)
    print("Left Mic: " + micleft_assign)

    micright_assign = random.choice(mic_list)
    mic_list.remove(micright_assign)
    stage_list.remove(micright_assign)
    sound_list.remove(micright_assign)
    print("Right Mic: " + micright_assign)

    sound_assign = random.choice(sound_list)
    print("Sound: " + sound_assign)

You have four lists. One is the master list and the others are specialty lists. There is no guarantee that a person will be added to anything but the master list, and may be added to only one of the specialty lists. However, when you do a create_assignment, you remove the person from every specialty list. I suggest you either test to see if the person is in a list before doing the remove, or put each remove into a try/except block. Probably more concise if you just do the test.

if micleft_assign in mic_list:
    mic_list.remove(micright_assign)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.