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.




(chp09_4)

Check your understanding

list-5-1: What is printed by the following statements?

alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False]
print(3.14 in alist)



list-5-2: What is printed by the following statements?

alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False]
print(57 in alist)



Następna część - Concatenation and Repetition