1>>> df
2 countries
30 US
41 UK
52 Germany
63 China
7>>> countries
8['UK', 'China']
9>>> df.countries.isin(countries)
100 False
111 True
122 False
133 True
14Name: countries, dtype: bool
15>>> df[df.countries.isin(countries)]
16 countries
171 UK
183 China
19>>> df[~df.countries.isin(countries)]
20 countries
210 US
222 Germany
1arr = ['a','b','c','d','e','f']
2
3if 'g' not in arr:
4 print('g is not in the list')
1a = [1, 2, 3, 4, 5, 6]
2b = 7
3c = 4
4
5# use "not in" to check if something is not an element of a list
6# use "in" to check if something is an element of a list
7
8if b not in a:
9 print('True')
10else:
11 print('False')
12
13if c in a:
14 print('True')
15else:
16 print('False')
17