I have a list of objects and I want to compare a string(actually int but I can cast it to str) to check of any of the object in the the list has that string as a member.
Now there is way in which I can iterate over all objects and compare val1
member with my string, but I was wondering if it is possible to do the way below?
class Check:
def __init__(self, val1):
self.val1 = val1
def __str__(self):
return str(self.val1)
o1 = [Check(100)]
test = "100"
for x in o1:
print(x)
print(test in o1)
but the print(test in o1)
return false