# List Membership¶

in and not in are boolean operators that test membership in a sequence. We used them previously with strings and they also work here.

rec-5-20: What is printed by the following statements?

alist = [3, 67, "cat", 3.14, False]
print "cat" in alist

• (A) True
• Yes, 'cat' is an item in the list alist.
• (B) False
• There are 5 items in the list, 'cat' is one of them.

rec-5-21: What is printed by the following statements?

alist = [3, 67, "cat", 3.14, False]
print "at" in alist

• (A) True
• "at" is in "cat", but it is not in alist
• (B) False
• Yes, "at" is not in the top level item, alist. It is in one of the elements of alist.
Next Section - Concatenation and Repetition