I am writing a program that has two lists set up, and then the user is prompted for input. I want to tell the program to do one thing if the users answer is found in one list, and do another thing entirely if the variable is in the second list.

I was thinking I could use an if statement but I dont know how to word it,

I need a way to say this in python:

if variable1 is in list1:
      print "You don't occupy that area!"
if variable1 is in list2:
      print "okay, now we're going to...."

You were very close:

# search lists

mammal_list = ['cat', 'dog', 'ape', 'cow']
bird_list = ['chicken', 'crow', 'quail', 'finch']

animal = raw_input("Enter an animal: ")

if animal in mammal_list:
    print "This animal is a mammal"
elif animal in bird_list:
    print "This animal is a bird"
    print "This animal is not on any list"
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.