I have a very large list of objects (the things that you can make with Classes, yeah?). I want to go through this list and remove objects if they have certain values. I'm going to then use the sorted list to pick out random elements and use them for other things.
Should I be using dictionaries or arrays or something instead of objects and lists? I am very new to this, I am sorry if it is very simple or I've done something wrong.
Example:
class Person:
def __init__(self, name, gender, otherVar, otherVar2):
self.name = name
self.gender = gender
self.otherVar = otherVar
self.otherVar2 = otherVar2
## also more variables if that makes a difference
John = Person("John", boy, otherVar, otherVar2)
Jane = Person("Jane", girl, otherVar, otherVar2) ## etcetera
myList = [John, Jane, Mary, Derek, Bob, Sue]
simpleThingThatIdoNotUnderstand(): ## removes all the
## girls
myList = [John, Derek, Bob]
I understand I need some sort of loop through the list (though there are so many ways, I am not sure which one will work), but how do I reference a value of an object in the list? Like 'if gender = girl, remove item'