Checkpoint 9.5.1.
- True
- Yes, 3.14 is an item in the list
a_list
. - False
- There are six items in the list; 3.14 is one of them.
What is printed by the following statements?
a_list = [3, 67, "cat", 910.0, 3.14, False]
print(3.14 in a_list)
in
and not in
are boolean operators that test membership in a sequence. We used them previously with strings and they also work here..index()
function. It will return the index where the item is in the list—but if the item is not in the list, it will generate a ValueError
.in
operator to make a function that gives us a “safe” index:safe_index
function isn’t built in to the list
class, we cannot use it with dot notation.a_list = [3, 67, "cat", 910.0, 3.14, False]
print(3.14 in a_list)
a_list
.