Using in operator to check the membership
Membership checking
in
is the membership operator.
It can be used in conditions, just like all the other comparison operators:
name = 'java2s.com'
if 's' in name:
print 'Your name contains the letter "s".'
else: # w w w . ja v a 2 s.c o m
print 'Your name does not contain the letter "s".'
The code above generates the following result.