Problem getting objects in python

Hi i’m trying to get objects by name and properties but it doesnt work. Whats wrong with my code?

    for obj in objs:
        if 'MenuItem' in obj and obj == active_item:
            print("It Worked!")
        else:
            print("Fuck shit!!")

Name of property is ‘MenuItem’ and variable ‘active_item’ is exactly the same as the object name. If i search only for the property name it works. No error in console, btw.

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

import bge
scene = bge.logic.getCurrentScene()

objs = scene.objects
active_item = 'Cube'

for obj in objs:
        if 'MenuItem' in obj and obj.name == active_item:
            print("It Worked!")
        else:
            print("bad words")

Are they literally the same object, or are they different instances of the same object that have the same name?

If you’ve already got a reference to the object you’re after (“active_item”), then why do you need to do a loop? Can’t you just modify it directly?

hard to tell, the code snipped is incomplete

active_item is a string used to validate the object name. It’s working fine now, thanks.