how can i know if a object in a list has a property?

hey!
so the title says it all
how can i know if a object in a list has X property, and then print that object?
i think it should use the for in method to search in the list, but i tried it and couldn`t make it work



for obj in objectlist:
     if 'hello' in obj:
        print (obj)


EDIT: Alternatively, you could use a list comprehension:



withprop = [o for o in objectlist if 'hello' in o] # Make a list of objects in the objectlist that have the property named 'hello'

print (withprop)


thanks SolarLune, it works nice!
it was way more simple of what i was thinking of
thanks again!