Hello, I’ve seen a couple of things on various posts scattered throughout the internet, but none that quite matches my needs.
I have 10 separate Global lists in my game. They are normally housing anywhere between 0-6 items
I am attempting to run a script that will move a given object to a new list, while removing it from any others.
Here is an example:
List1 =  List2 = ["Blue"] List3 = ["Yellow", "Orange", "Gold"] List4 = ["Red"] Listcomp = [List1, List2, List3, List4] def Strip(item, lists, except): for sublist in lists: if sublist != except: for item in sublist: sublist.remove(item) if item not in except: except.append(item) Strip("Red", Listcomp, List1)
I realize that the way I have this set up I am asking python to look at “” instead of “List1” (as well as nesting the contents of the lists and not the list names) yet I don’t know how to do this without having to rewrite code 10 different times to exchange “except” with the searched list.
The goal would be to have a function that could pull “Red” out of every list except a single targeted list, and if it is not already in that list, add it.