``````

In [1]:

print(1 in [0, 1, 2])

``````
``````

True

``````
``````

In [2]:

print(100 in [0, 1, 2])

``````
``````

False

``````
``````

In [3]:

print(1 in (0, 1, 2))

``````
``````

True

``````
``````

In [4]:

print(1 in {0, 1, 2})

``````
``````

True

``````
``````

In [5]:

print(1 in range(3))

``````
``````

True

``````
``````

In [6]:

l = [0, 1, 2]
i = 0

if i in l:
print('{} is a member of {}.'.format(i, l))
else:
print('{} is not a member of {}.'.format(i, l))

``````
``````

0 is a member of [0, 1, 2].

``````
``````

In [7]:

l = [0, 1, 2]
i = 100

if i in l:
print('{} is a member of {}.'.format(i, l))
else:
print('{} is not a member of {}.'.format(i, l))

``````
``````

100 is not a member of [0, 1, 2].

``````
``````

In [8]:

l = [0, 1, 2]

if l:
print('not empty')
else:
print('empty')

``````
``````

not empty

``````
``````

In [9]:

l = []

if l:
print('not empty')
else:
print('empty')

``````
``````

empty

``````
``````

In [10]:

d = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}

``````
``````

In [11]:

print('key1' in d)

``````
``````

True

``````
``````

In [12]:

print('value1' in d)

``````
``````

False

``````
``````

In [13]:

print('value1' in d.values())

``````
``````

True

``````
``````

In [14]:

print(('key1', 'value1') in d.items())

``````
``````

True

``````
``````

In [15]:

print(('key1', 'value2') in d.items())

``````
``````

False

``````
``````

In [16]:

print('a' in 'abc')

``````
``````

True

``````
``````

In [17]:

print('x' in 'abc')

``````
``````

False

``````
``````

In [18]:

print('ab' in 'abc')

``````
``````

True

``````
``````

In [19]:

print('ac' in 'abc')

``````
``````

False

``````
``````

In [20]:

print(10 in [1, 2, 3])

``````
``````

False

``````
``````

In [21]:

print(10 not in [1, 2, 3])

``````
``````

True

``````
``````

In [22]:

print(not 10 in [1, 2, 3])

``````
``````

True

``````
``````

In [23]:

print(not (10 in [1, 2, 3]))

``````
``````

True

``````
``````

In [24]:

print((not 10) in [1, 2, 3])

``````
``````

False

``````
``````

In [25]:

print(not 10)

``````
``````

False

``````
``````

In [26]:

print(False in [1, 2, 3])

``````
``````

False

``````
``````

In [27]:

print([0, 1] in [0, 1, 2])

``````
``````

False

``````
``````

In [28]:

print([0, 1] in [[0, 1], [1, 0]])

``````
``````

True

``````
``````

In [29]:

l = [0, 1, 2]
v1 = 0
v2 = 100

``````
``````

In [30]:

print(v1 in l and v2 in l)

``````
``````

False

``````
``````

In [31]:

print(v1 in l or v2 in l)

``````
``````

True

``````
``````

In [32]:

print((v1 in l) or (v2 in l))

``````
``````

True

``````
``````

In [33]:

l1 = [0, 1, 2, 3, 4]
l2 = [0, 1, 2]
l3 = [0, 1, 5]
l4 = [5, 6, 7]

``````
``````

In [34]:

print(set(l2) <= set(l1))

``````
``````

True

``````
``````

In [35]:

print(set(l3) <= set(l1))

``````
``````

False

``````
``````

In [36]:

print(set(l1).isdisjoint(set(l4)))

``````
``````

True

``````
``````

In [37]:

print(not set(l1).isdisjoint(set(l3)))

``````
``````

True

``````
``````

In [38]:

l = [0, 1, 2]

for i in l:
print(i)

``````
``````

0
1
2

``````
``````

In [39]:

print([i * 10 for i in l])

``````
``````

[0, 10, 20]

``````