I have a list which is of type class people.

def class people:
name=""
age=0

class poeple has two data members name, age

I have a list of all person stating in the city as a list of objects of this class.list is called population

now i get an query to check if the person stays in the city.this is called queryperson

I used:
if(queryperson in population):
print( "person lives")
else:
print( "person does not live here")

However i always get person does not live here. Any clues on how to do this ?

Thank you for your help

I used:
if (queryperson in population):

Print the list "population" and see what it contains.

Please use code tags. You will get more answers to your question if your post is friendlier to read. To do this, you simply place tags around your code like so:

[code=python] # This is where your code goes # In here between the code tags

[/code]

Doing this will give you pretty syntax highlighting and preserve your indentation. And your post won't look like a mess of text.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.