Object in List : how?

Khairil Sitanggang ksit70 at gmail.com
Sat Jul 23 00:28:11 EDT 2022


Hello Expert:

I just started using python. Below is a simple code.  I was trying to check
if, say, NO1 is not in the NODELIST[:].NO
How can I achieve this purpose?

Regards,
-Irfan


class Node:
    def __init__(self):
        self.NO = 0
        self.A = 20

NODE = Node()
NODELIST = []

NODE.NO = 10
NODELIST.append(NODE)

NODE.NO = 20
NODELIST.append(NODE)

NODE.NO = 30
NODELIST.append(NODE)


NO1 = 20
if NO1 not in NODELIST[:].NO  ???


More information about the Python-list mailing list